Bug 400628 - Error Attempting Backup to Samba share - Windows 10
Summary: Error Attempting Backup to Samba share - Windows 10
Status: RESOLVED FIXED
Alias: None
Product: kmymoney
Classification: Applications
Component: file (show other bugs)
Version: unspecified
Platform: Microsoft Windows Microsoft Windows
: NOR normal
Target Milestone: ---
Assignee: KMyMoney Devel Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-11-03 16:13 UTC by Robert Blackwell
Modified: 2019-01-26 19:03 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 5.0.3


Attachments
Screen Shot of config and error windows (5.58 KB, image/png)
2018-11-03 16:13 UTC, Robert Blackwell
Details
Set Backup Path, Mount directory (24.70 KB, image/png)
2018-11-04 13:26 UTC, Robert Blackwell
Details
Message: Mounting Drive, Saving File (16.38 KB, image/png)
2018-11-04 13:28 UTC, Robert Blackwell
Details
Set Backup Path, Mapped Drive (20.76 KB, image/png)
2018-11-05 00:24 UTC, Robert Blackwell
Details
Set Backup Path, Local Drive (Desktop) - Using File Picker (24.59 KB, image/png)
2018-11-05 17:23 UTC, Robert Blackwell
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Robert Blackwell 2018-11-03 16:13:46 UTC
Created attachment 116065 [details]
Screen Shot of config and error windows

SUMMARY

Unable to save backup file; "Error copying file to device".


STEPS TO REPRODUCE
1. Select File>Backup
2. Select destination for backup file (Note: Have tried local desktop as well as Samba share.)
3. Press okay

OBSERVED RESULT
An error occurs immediately following press of "Ok" button on "Backup - KMyMoney" Window. The error reads "Error copying file to device." 

EXPECTED RESULT
Working file backed up to destination location (Samba NAS)

SOFTWARE VERSIONS
KMyMoney Version 5.0.80.6b49f80d
Windows 10 Pro, Version 10.0.17234 Build 17134

ADDITIONAL INFORMATION
Comment 1 Jack 2018-11-03 20:54:40 UTC
There have been some issues with Samba file shares.  From memory, it was related to particular implementation of the Samba server.  To avoid that issue for now, let's start with plain text file on the local file system.  First, please confirm that you can do a plain File/Save or File/Save as....  If that works, then on then screen prior to the error, have you checked the box about mounting the file system before backing up?  Perhaps you can attache a screen shot of that dialog.
Comment 2 Robert Blackwell 2018-11-04 13:23:58 UTC
Jack,

An XML file is in use. If a local device is utilized for the backup point then a backup completes as expected. No errors are encountered, the backup file may be opened and utilized.

Despite selecting the "Mount this directory before backing up" dialog, changing the backup location to either a Samba share or a mapped share results in an error. I noticed a related issue; when electing to "Mount this directory before backing up" a dialog that reads "Mounting " with a progress bar appears at the bottom of the screen. The bar never moves off zero. It remains on the screen until KMyMoney is closed.

Two screen shots are attached for reference.
Comment 3 Robert Blackwell 2018-11-04 13:26:03 UTC
Created attachment 116080 [details]
Set Backup Path, Mount directory

Screen shot of Backup dialog window. Shows Samba path and "Mount directory..." text.
Comment 4 Robert Blackwell 2018-11-04 13:28:05 UTC
Created attachment 116081 [details]
Message: Mounting Drive, Saving File

Shows what happens when the "Mount directory..." option is used with a Samba.
Comment 5 Thomas Baumgart 2018-11-04 16:27:02 UTC
Using the mount option on windows does not make sense. We might have to disable it. For now don't mark it. I have duplicated the problem and need to investigate this a bit.
Comment 6 Jack 2018-11-04 16:36:57 UTC
Looks like Thomas and I replied at the same time.  As Thomas suggests, be sure the share is already mounted before backing up, and try without ticking the "mount" box.  

Thomas - there are cases where mounting on Windows does make sense (such as a USB thumb drive, or possibly even a Samba share not normally mounted.)  If the KMM code for mounting is known not to work on Windows, then it would make sense to replace the "mount" checkbox with something like "If the target directory is on an external file system, please be sure it is mounted before backing up." or something like that.  Do we know whether there is a similar issue on the MacPorts version?
Comment 7 Thomas Baumgart 2018-11-04 17:52:08 UTC
The current KMyMoney code simply executes

   mount <<path-provided-in-dialog-as-mountpoint>>

when the check mark is checked. That will certainly not help on Windows.

Performing the backup is done using the 'cp' (unix) and 'copy' (windows) command line utilities. I wonder if it might be more intelligent to rename the current mount-point into destination folder and use some kio slave magic to do the copy job. This code comes a long way from KDE3 (or even KDE2). Using the KDE tools we will be able to even store the file in a cloud (like nextcloud).
Comment 8 Ralf Habacker 2018-11-04 18:51:22 UTC
There were some related fixes in 4.8 branch. See bug 302945 for details.
Comment 9 Robert Blackwell 2018-11-04 21:47:03 UTC
I'll keep an eye on this thread and gladly test any changes.
Comment 10 Jack 2018-11-04 23:11:18 UTC
Ralf,  per his first post, he's using KMyMoney Version 5.0.80.6b49f80d. (I'm not sure how to designate that in the version dropdown, unless we add entries for git(4.8) and git(5.0).  Anyway, given Thomas' comment, it is using copy, not cp.

Robert - per several comments, what happens if the Samba share is already mounted, and you do NOT check the "mount" box?
Comment 11 Robert Blackwell 2018-11-05 00:22:15 UTC
Mapping a share to a windows drive, Y:/ in this case, results in the same error. Note the "Mount directory..." option was left unchecked.
Comment 12 Robert Blackwell 2018-11-05 00:24:05 UTC
Created attachment 116091 [details]
Set Backup Path, Mapped Drive

Attempt to save to a mapped drive.
Comment 13 Ralf Habacker 2018-11-05 07:52:24 UTC
(In reply to Jack from comment #10)
 Anyway, given Thomas' comment, it is using copy, not cp.
I refer to the mentioned mount option for Windows, which is disabled by the following patch https://cgit.kde.org/kmymoney.git/commit/?id=da03f3b25c3a193b6ea0e9c9c08abe406ecdc97e. It looks that this commit is not in 5.0 branch
Comment 14 Jack 2018-11-05 16:44:37 UTC
Robert: Did you choose that directory from the file chooser dialog or type it in?  I don't think in needs the leading slash, and the second slash might need to be a backslash.  Can you try it without the leading slash, and then with the other slash made a backslash?  It might also be worth trying the latest version, since I think Thomas added some debugging output which might provide more information.
Comment 15 Robert Blackwell 2018-11-05 17:23:25 UTC
Created attachment 116107 [details]
Set Backup Path, Local Drive (Desktop) - Using File Picker

Set Backup Path, Local Drive (Desktop) - Using File Picker
Comment 16 Robert Blackwell 2018-11-05 17:33:39 UTC
Jack,

I've update to the latest Unstable Nightly build; Version 5.0.80-bda8e4a0

The file name in the screen shot was entered using the file picker. I've tried omitting the first slash and changing the second slash without any change - the error persists.

How do I go about securing additional data for the team to review?
Comment 17 Ralf Habacker 2018-11-05 17:56:50 UTC
(In reply to Thomas Baumgart from comment #7)
> The current KMyMoney code simply executes
> 
>    mount <<path-provided-in-dialog-as-mountpoint>>
> 
> when the check mark is checked. That will certainly not help on Windows.
> 
> Performing the backup is done using the 'cp' (unix) and 'copy' (windows)
> command line utilities. I wonder if it might be more intelligent to rename
> the current mount-point into destination folder and use some kio slave magic
> to do the copy job. This code comes a long way from KDE3 (or even KDE2).
> Using the KDE tools we will be able to even store the file in a cloud (like
> nextcloud).
yes, this was fixed with bug 384139. The related commit is https://cgit.kde.org/kmymoney.git/commit/?id=9771cfa20fbf2d6bd2e63fea0aefc410d720b870 or look at the related source location at https://cgit.kde.org/kmymoney.git/tree/kmymoney/kmymoney.cpp?h=4.8#n2690
Comment 18 Thomas Baumgart 2018-11-05 20:52:25 UTC
Just that this does not work in KF5 as KIO::NetAccess is deprecated (see https://community.kde.org/Frameworks/Porting_Notes#KIO_Changes for details).
Comment 19 Robert Blackwell 2019-01-13 22:02:55 UTC
I'm now running Version 5.0.80-cfd484f5. This problem is resolved.
Comment 20 Jack 2019-01-13 22:18:40 UTC
Before we close this as FIXED, can Ralf or Thomas say if there was a KMM commit to fix this, or whether there might have been a change in some other part of KDE?
Comment 21 Thomas Baumgart 2019-01-14 10:33:44 UTC
This could well be. I found a comment (my own) on bug 302945 which points to https://commits.kde.org/kmymoney/be3dfc7d78cda1794a4597abe7f0fa13b5a375bc that could solve as fix. If we have confidence that this is really solved, then we can close this one and bug 302945 and mark them as fixed in 5.0.3. The version that Rob refers to contains this fix.
Comment 22 Robert Blackwell 2019-01-14 16:44:32 UTC
I'm able to confirm backup is working in Version 5.0.80-cfd484f5.