Duplicity: Difference between revisions

From miki
Jump to navigation Jump to search
Line 6: Line 6:


== Basic usage ==
== Basic usage ==
;Relative vs absolute paths
* In all examples below, the paths on the remote server are '''relative''' (<code>ftp://FtpUserID@ftp.domain.com/etcunset</code>, <code>scp://scp_user@scp.domain.com/var/</code>).
* To use an '''absolute''' path, one must add an '''extra''' slash, like in <code>scp://scp_user@scp.domain.com//absolute/path/to/var/</code>.

;Basic backup:
;Basic backup:
<source lang=bash>
<source lang=bash>
Line 27: Line 31:
;Collection status
;Collection status
<source lang="bash">
<source lang="bash">
duplicity collection-status scp://scp_user@scp.domain.com/var/ var
jjjj
</source>
</source>


Line 33: Line 37:
;Basic file listing:
;Basic file listing:
<source lang=bash>
<source lang=bash>
# Note that remote paths are RELATIVE to user HOME directory.
# Absolute paths would require an extra /:
#
# duplicity list-current-files scp://scp_user@scp.domain.com//absolute/path/to/var/ var

# Using ftp
# Using ftp
duplicity list-current-files ftp://FtpUserID@ftp.domain.com/etcunset PASSPHRASE
duplicity list-current-files ftp://FtpUserID@ftp.domain.com/etcunset PASSPHRASE
Line 47: Line 46:
;Basic restore
;Basic restore
<source lang=bash>
<source lang=bash>
# Restore latest backup from /etc here
# Note that remote paths are RELATIVE to user HOME directory.
# Absolute paths would require an extra /:
#
# duplicity restore scp://scp_user@scp.domain.com//absolute/path/to/var/ .

duplicity ftp://FtpUserID@ftp.domain.com/etc .
duplicity ftp://FtpUserID@ftp.domain.com/etc .

# Restore /etc as it was 3 days ago
duplicity --time 3D ftp://FtpUserID@ftp.domain.com/etc .

# Restore only one file
duplicity --file-to-restore apt/sources.list ftp://FtpUserID@ftp.domain.com/etc /home/user/sources.list
duplicity --file-to-restore apt/sources.list ftp://FtpUserID@ftp.domain.com/etc /home/user/sources.list
</source>
</source>

Revision as of 17:41, 17 April 2019

Installation

See DuplicityBackupHowto.

sudo apt-get install duplicity
sudo apt-get install ncftp            # to use duplicity ftp backup

Basic usage

Relative vs absolute paths
  • In all examples below, the paths on the remote server are relative (ftp://FtpUserID@ftp.domain.com/etcunset, scp://scp_user@scp.domain.com/var/).
  • To use an absolute path, one must add an extra slash, like in scp://scp_user@scp.domain.com//absolute/path/to/var/.
Basic backup
export PASSPHRASE=SomeLongGeneratedHardToCrackKey
export FTP_PASSWORD=WhateverPasswordYouSetUp
duplicity /etc ftp://FtpUserID@ftp.domain.com/etc
unset PASSPHRASE
unset FTP_PASSWORD

(or change ftp URL: to file:///my/filesystem/path).

Basic verify (compare)
export PASSPHRASE=SomeLongGeneratedHardToCrackKey
export FTP_PASSWORD=WhateverPasswordYouSetUp
duplicity verify ftp://FtpUserID@ftp.domain.com/etc /etc
unset PASSPHRASE
unset FTP_PASSWORD
Collection status
duplicity collection-status scp://scp_user@scp.domain.com/var/ var


Basic file listing
# Using ftp
duplicity list-current-files ftp://FtpUserID@ftp.domain.com/etcunset PASSPHRASE

# Using scp, and GPG
duplicity --encrypt-key $ENCRKEY --sign-key $SIGNKEY list-current-files scp://scp_user@scp.domain.com/var/ var
Basic restore
# Restore latest backup from /etc here
duplicity ftp://FtpUserID@ftp.domain.com/etc .

# Restore /etc as it was 3 days ago
duplicity --time 3D ftp://FtpUserID@ftp.domain.com/etc .

# Restore only one file
duplicity --file-to-restore apt/sources.list ftp://FtpUserID@ftp.domain.com/etc /home/user/sources.list

Cron script

export PASSPHRASE=(insert your value here)
export FTP_PASSWORD=(insert your value here)

# doing a monthly full backup (1M)
duplicity --full-if-older-than 1M /etc ftp://(insert your FTP server here)/etc
# exclude /var/tmp from the backup
duplicity --full-if-older-than 1M --exclude /var/tmp /var ftp://(insert your FTP server here)/var
duplicity --full-if-older-than 1M /root ftp://(insert your FTP server here)/root

# cleaning the remote backup space (deleting backups older than 6 months (6M, alternatives would 1Y fo 1 year etc.)
duplicity remove-older-than 6M --force ftp://(insert your FTP server here)/etc
duplicity remove-older-than 6M --force ftp://(insert your FTP server here)/var
duplicity remove-older-than 6M --force ftp://(insert your FTP server here)/root

unset PASSPHRASE
unset FTP_PASSWORD

Install in crontab (crontab -e) by adding line:

0 0 * * * /root/scripts/etc/backup.sh >>/var/log/duplicity/etc.log