Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Is it possible to backup a remote directory to a local path?

Using two URL in the command raises

Two URLs specified.  One argument should be a path.

Using only one for the remote but specifying the full option raises

--full option cannot be used when restoring or verifying

What I tried looks like

duplicity full ssh://username@remote:XXXX/home/username /media/removabledrive/

with XXXX being a custom port for ssh.

share|improve this question

3 Answers 3

up vote 5 down vote accepted
+50

Why not just mount the remote path into your local filesystem tree using sshfs, cifs, nfs or some other facility of your choosing?

If you do that, you can specify two local paths to duplicity and it shouldn't notice that one of the paths is actually on a remote node (make sure you choose the remote file system that exports attributes like permissions etc. in a way you want and also make sure you use correct mount options - which is especially important for samba/cifs, since its defaults are not very unix-ish).

For a Debian or Debian derivatives (like Ubuntu):

apt-get install sshfs

Then:

mkdir -p /mnt/remote &&
sshfs username@remote:/home/username /mnt/remote

After that succeeds, do your backup from /mnt/remote to your local backup path, then

umount /mnt/remote

Also check out man sshfs to see what options might apply to your use case.

share|improve this answer
    
Good idea! The only caveat is that file exclusion does not seem to work properly. –  Alfred M. Oct 6 '13 at 17:28

Looking at the documentation here: http://duplicity.nongnu.org/docs.html It looks like you should be issuing this:

duplicity full ssh://username@remote:XXXX//home/username /media/removabledrive/

Notice the double // after the host:port

share|improve this answer
    
I still get the message Command line error: --full option cannot be used when restoring or verifying. –  Alfred M. Oct 4 '13 at 8:19

From what I understand, supplying remote path followed by local path imposes restoring data, which should be a full restore by default.

"full" parameter is only valid for making backups:

   full   Indicate full backup.  If this is set, perform full backup  even
          if signatures are available.

   incr   If  this  is  requested an incremental backup will be performed.
          Duplicity will abort if old signatures  cannot  be  found.   The
          default is to switch to full backup under these conditions.

So this command: duplicity full /home/me scp://uid@other.host/some_dir will make a full backup of /home/me to remote host/some_dir. Full/incr only applies to MAKING backups, not restoring.

If you want to restore only certain path, then use:

--file-to-restore path This option may be given in restore mode, causing only path to be restored instead of the entire contents of the backup archive. path should be given relative to the root of the directory backed up.

According to documentation here: http://manpages.ubuntu.com/manpages/oneiric/man1/duplicity.1.html , what happens is:

When restoring, duplicity applies patches in order, so deleting, for instance, a full backup set may make related incremental backup sets unusable.

Also, last remark about the "ssh://" part. Try using scp/sftp, as according to documentation:

A NOTE ON SSH/SCP PROTOCOLS

   Duplicity specifies two protocol names for the same protocol.  This  is
   a  known  and  user-confusing issue.  Both use the same protocol suite,
   namely ssh through its' utility routines scp and sftp.  Older  versions
   of  duplicity used scp for get and put operations and sftp for list and
   delete  operations.   The  current  version  uses  sftp  for  all  four
   supported  operations, unless the --use-scp option is used to revert to
   old behavior.  The change was made to all-sftp in order  to  allow  the
   remote system to chroot the backup, thus providing better security.
share|improve this answer
    
I am indeed trying to create a backup. My problem is precisely that duplicity infer the action to perform from the relative position of the URL and local path. I tried the rsync backend with no success. I'll give a go on scp. –  Alfred M. Oct 4 '13 at 14:27
    
If you try to perform a backup from remote host to a local machine and can consider rsync as well, you can try it with: rsync -avz foo:src/bar /data/tmp This would recursively transfer all files from the directory src/bar on the machine foo into the /data/tmp/bar directory on the local machine. –  Jacek Lakomiec Oct 4 '13 at 14:30
    
Alternatively you can do it with one command: At local machine run: ssh root@remotehost 'duplicity full /home/username ssh://username@local:port//media/removabledrive/' –  Jacek Lakomiec Oct 4 '13 at 14:48
    
I thought about the first one but that would become awkward when there are lots of data to backup. The problem of your second suggestion is that I can ssh in only one way from local to remote. –  Alfred M. Oct 4 '13 at 15:19
    
If you can ssh from local to remote, then you can use ssh tunneling and forward local port on the local machine to remote host:port, either temporarily just during the backup procedure or permanently. Check man ssh for details, look at -L options. –  Jacek Lakomiec Oct 4 '13 at 18:29

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.