Faulty OK with failing mega backend
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Duplicity |
New
|
Undecided
|
Unassigned |
Bug Description
Duplicity 0.7.16
Megatools 1.9.97
Xubuntu 16.04.3
I have found some problem while using the mega backend.
1) Not possible to specify user (mega:/
2) Folder at cloud not automatic created.
3) OK even if mega backend commands fails! MAJOR
4) This is written in megabackend.py: """Connect to remote store using Mega.co.nz API"""
However it isn't true. The megatools are used.
5) If no files found in backend -> "Local and Remote metadata are synchronized, no sync needed."
How can it be in sync if no files found at one end.
Example:
"
$ PASSPHRASE="abc" duplicity --include '/home/
mkdir: Tmp2
megals: /Root/Tmp2
Local and Remote metadata are synchronized, no sync needed.
megals: /Root/Tmp2
Last full backup date: none
No signatures found, switching to full backup.
megarm: duplicity-
megaput: duplicity-
megarm: duplicity-
megaput: duplicity-
megarm: duplicity-
megaput: duplicity-
megals: /Root/Tmp2
--------------[ Backup Statistics ]--------------
StartTime 1517056520.00 (Sat Jan 27 13:35:19 2018)
EndTime 1517056520.57 (Sat Jan 27 13:35:20 2018)
ElapsedTime 0.57 (0.57 seconds)
SourceFiles 676
SourceFileSize 11869399 (11.3 MB)
NewFiles 676
NewFileSize 11869399 (11.3 MB)
DeletedFiles 0
ChangedFiles 0
ChangedFileSize 0 (0 bytes)
ChangedDeltaSize 0 (0 bytes)
DeltaEntries 676
RawDeltaSize 11599063 (11.1 MB)
TotalDestinatio
Errors 0
-------
$ echo $?
0
"
Note that all seems to be okay above. However no files have been uploaded to the cloud, none!
It turns out that the megatools is bad. However bugs have been fixed since the version in Ubuntu (1.9.97). This version of the tools always return 0 (OK). Latest source code doesn't.
So the biggest problem is the old and bad megatools. However I think duplicity should include some kind of check for this major fault. I notice duplicity do a _list in backend after put up files. Maybe it could be possible to use this answer (list of files) and check that the files that was just uploaded actually is in the list.
Here is a proposal for one quick check that can be added to discover when megatools fails. Check that megals have got an answer from the server. The "/Root" folder should always be there or the folder that is given as argument, if it exist.
I have done some changes in megabackend.py
"
--- duplicity/
+++ duplicity/
@@ -28,7 +28,7 @@
class MegaBackend(
- """Connect to remote store using Mega.co.nz API"""
+ """Connect to MEGA cloud (mega.nz) using Megatools"""
def __init__(self, parsed_url):
@@ -128,6 +128,10 @@
files = subprocess.
files = files.strip(
+ # ensure communication with server
+ if self._folder not in files:
+ raise BackendExceptio
+
# remove the folder name, including the path separator
files = [f[len(
@@ -161,7 +165,12 @@
cmd = ['megaput', '-u', self._username, '-p', self._password, '--no-progress',
- self.subprocess
+ result = subprocess.
+ result = result.rstrip()
+ if result:
+ print (result)
+ if "ERROR" in result:
+ raise BackendExceptio
def delete(self, remote_file):
"
Note: It can be discussed if check for "ERROR" string should be done or check for not empty result string. I don't know if all kinds of faults print ERROR.
I have done some tests, here are printouts from failed executions (with my patch)...
megals 1.9.97 fails (this is the same typ of execution as above):
"
mkdir: Test22
megals: /Root/Test22
Attempt 1 failed. BackendException: folder '/Root/Test22' not found or communication error!
"
megaput 1.9.97 fails:
"
mkdir: Test22
megals: /Root/Test22
Local and Remote metadata are synchronized, no sync needed.
megals: /Root/Test22
Last full backup left a partial set, restarting.
Last full backup date: Sat Jan 27 17:50:51 2018
RESTART: The first volume failed to upload before termination.
Restart is impossible.
mkdir: Test22
megals: /Root/Test22
Local and Remote metadata are synchronized, no sync needed.
megals: /Root/Test22
Last full backup date: none
No signatures found, switching to full backup.
megarm: duplicity-
megaput: duplicity-
ERROR: Upload failed for '/tmp/duplicity
Attempt 1 failed. BackendException: error from megaput!
"
megals 1.9.98 fails:
"
mkdir: Test22
megals: /Root/Test22
Attempt 1 failed. BackendException: folder '/Root/Test22' not found or communication error!
"
megaput 1.9.98 fails:
"
mkdir: Test22
megals: /Root/Test22
Local and Remote metadata are synchronized, no sync needed.
megals: /Root/Test22
Last full backup left a partial set, restarting.
Last full backup date: Sun Jan 28 13:24:38 2018
RESTART: The first volume failed to upload before termination.
Restart is impossible.
mkdir: Test22
megals: /Root/Test22
Local and Remote metadata are synchronized, no sync needed.
megals: /Root/Test22
Last full backup date: none
No signatures found, switching to full backup.
megarm: duplicity-
megaput: duplicity-
Attempt 1 failed. CalledProcessError: Command '['megaput', '--config', '/home/
"
I think both old and new megatools should be supported. However maybe it can depend on which versions will be included in apt repos.
Now I test with duplicity 0.7.16 (without my patch) and newer megatools 1.9.98:
"
mkdir: Test22
megals: /Root/Test22
Local and Remote metadata are synchronized, no sync needed.
megals: /Root/Test22
Last full backup left a partial set, restarting.
Last full backup date: Sun Jan 28 14:03:11 2018
RESTART: The first volume failed to upload before termination.
Restart is impossible.
mkdir: Test22
megals: /Root/Test22
Local and Remote metadata are synchronized, no sync needed.
megals: /Root/Test22
Last full backup date: none
No signatures found, switching to full backup.
megarm: duplicity-
megaput: duplicity-
Attempt 1 failed. BackendException: Error running 'megaput --config /home/surf/.megarc --no-progress --path /Root/Test22/
ERROR: Upload failed for '/tmp/duplicity
"
So here we actually get an error, however not on megals.
PS. Please excuse me, I'm a C/C++ developer and have never written python code. So I don't feel comfortable doing this. I hope some experianced python developer can check this out. Sorry, but I haven't made proposal to fix all problems I listed at top.
//Michael
I think mega:// user.name% <email address hidden>/Folder should be mega:// user.name% 40gmail. com:@mega. nz/Folder - colon after .com and before @mega.