Skip to content

Instantly share code, notes, and snippets.

@multidis
Created November 30, 2013 20:25
Show Gist options
  • Save multidis/7724025 to your computer and use it in GitHub Desktop.
Save multidis/7724025 to your computer and use it in GitHub Desktop.
Duplicity (incremental backups based on rsync) backup and restore commands. NOTE: Powerful tool for remote backup e.g. with Amazon S3 and encryption; commands below are however mostly about backing up and restoring on locally mounted drives without encryption.
### duplicity command examples
### http://www.nongnu.org/duplicity/duplicity.1.html
## backup home dir to remote drive
## NOTE: can use GUI for that
## list of files backed up on a mounted drive
duplicity list-current-files --no-encryption file:///media/USB300G/full-backup-dir-with-archives > /home/user/restore/list.txt
## NOTE: may run really long and create hundreds of Mb file if a lot was backed up
## restore a file from that list
## NOTE: path as in list.txt above, usually starts with home/... (no leading slash! check...)
duplicity restore --no-encryption --file-to-restore home/user/path/filename.ext file:///media/USB300G/full-backup-dir-with-archives /home/user/restore/filename.ext
## restore a directory Dirname
## NOTE: need to run this OUTSIDE restore-dir!
duplicity --no-encryption --file-to-restore home/user/Dirname file:///media/USB300G/full-backup-dir-with-archives /home/user/restore/Dirname
## last backup is restored by above command;
## if it was not a full backup, need earlier date when full backup was made;
## look up time stamp of the last full backup then and include --time option:
duplicity --no-encryption --file-to-restore home/user/Dirname --time 20131031T103712Z file:///media/USB300G/full-backup-dir-with-archives /home/user/restore/Dirname
## see duplicity manual for other time format options if needed
## restoring multiple files from a list (list-current-files above)
## if more custom situation use per-file commands:
#!/bin/bash
FILELIST=$1
DIR=$2
RESDIR=$3
MEDIA=$4
grep -P 'home.*' -o "$FILELIST" | while read -r line ; do
echo "$line"
RESTOR=$(echo "$line"|grep -P "$DIR.*" -o)
#echo "--file-to-restore $line $MEDIA $RESDIR/$RESTOR"
duplicity --no-encryption --file-to-restore "$line" "$MEDIA" "$RESDIR"/"$RESTOR"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment