duplicitybackup.sh – a helper script to manage duplicity backups

I frequently use duplicity to create encrypted (incremental) backups and upload them to a offsite ftp server. Duplicity is a great utility for creating encrypted incremental backups and saving them locally or pushing to a number of different kinds of remote sites. However some of the commands are somewhat cumbersome, long and not the easiest to remember if you aren’t using them frequently.

To save me time I created a simple script to help me manage my duplicity backups, it’s called duplicitybackup.sh

duplicitybackup.sh has the following features:

  • Creates encrypted full and incremental backups using duplicity
  • Backup multiple directories using duplicity
  • Upload encrypted duplicity backups to a remote ftp server
  • Verify remote duplicity backup’s and show changes
  • Easily restore remote duplicity backups
  • Delete remote duplicity backups
  • List files in duplicity backups
  • Show status of duplicity archive
  • Display the log file for the last duplicity backup
  • List the duplicity backup files on your remote ftp server
  • Email reports to you in the event of a duplicity backup containing errors

duplicitybackup.sh is hosted on github, you can find the project repo here – duplicitybackup.sh github repo.

To download the latest version of the script:

wget https://raw.github.com/prae5/duplicitybackup.sh/master/duplicitybackup.sh
chmod a+x duplicitybackup.sh

Once you have downloaded it there are a few basic configuration options you need to set. Open duplicitybackup.sh in your favourite editor and set the following options. They should all be self explanatory.

########################################################
## BASE CONFIG OPTIONS                                ##
## All details must be configured                     ##
########################################################
FTP_USER=
FTP_PASS=
FTP_SERVER=
GPG=
LOGFILE=/tmp/duplicity.log
########################################################

########################################################
## BASE CONFIG OPTIONAL OPTIONS                       ##
## Set EMAIL to recieve backup error reports          ##
########################################################
EMAIL=

########################################################
## DUPLICITY BACKUP LOCTIONS                          ##
## Enter locations to backup / exclude                ##
## Multiple directories supported, space seperated    ##
BACKUP_LOCATIONS="/home"
BACKUP_EXCLUDES=""
########################################################

Once you set these options, you are nearly ready to run your first duplicity backup. Before you do this, you must create a directory on your remote ftp server for duplicity to store its encrypted backups. To create this folder, run the following command:

./duplicitybackup.sh create

You are now ready to run your first backup. To do this, run (this may take a few minutes to a few hours depending on the size of your backup and network speed):

./duplicitybackup.sh backup

You can confirm your backup has been uploaded to the remote server by running:

./duplicitybackup.sh testftp

duplicity.sh usage options:


./duplicitybackup.sh create - This will create a remote working directory for uploading backups
 ./duplicitybackup.sh backup - This will backup your files and upload them to your remote server
 ./duplicitybackup.sh verify - Verify duplicity backup and show changes
 ./duplicitybackup.sh restore file [time] destination
- Restore files from your remote server
- You can optionally set the time of the file to restore
- (check duplicty TIME FORMATS for options)
 ./duplicitybackup.sh delete time - Delete backups older than [time]
 ./duplicitybackup.sh list - List files in the most recent duplicity backup
 ./duplicitybackup.sh status - List dupicity backup repository status
 ./duplicitybackup.sh log - Display last duplicity log file
 ./duplicitybackup.sh testftp - Test ftp connection and list directory contents

3 comments to duplicitybackup.sh – a helper script to manage duplicity backups

  • Drew

    Its a great script – thanks for the effort. Any thought to adding support for SCP?

    • admin

      SCP support wouldn’t be too hard to support – it would only need a few changes. If i get time over the next week or two I’ll post a scp based version.

  • roamer

    This message appears, when I put something for BACKUP_EXCLUDES= :
    ./duplicitybackup.sh backup
    Kommandozeilen-Fehler: Expected 2 args, got 3
    Rufen Sie duplicity mit der Option ‘–help’ auf, um eine Hilfeseite zu erhalten.
    Null message body; hope that’s ok

Add Comment Register



Leave a Reply

  

  

  

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>