Incremental Backups on Ubuntu using Duplicity with Samba

Based on Ubuntu 12.04, Samba client [1] and Duplicity [2].

  • Mount samba (see [1])
    • install cifs-utils
      sudo apt-get install cifs-utils
    • create file /home/your_username/Documents/.backup-samba-credentials with content

      username=your_samba_username 
      password=***
    • create mount directory

      mkdir /home/your_username/backup
    • edit /etc/fstab

      # samba - backup - kali
      //samba_server_ip/your_samba_username       /home/your_username/backup     cifs    credentials=/home/your_username/Documents/.backup-samba-credentials,uid=1000,gid=1000,noauto,users     0       0

      You can get the uid and the gid via

      id -u your_username # the uid
      id -g your_username # the gid
    • Now you can mount and unmount:
      mount /home/your_username/backup # mount
      umount /home/your_username/backup # unmount
  • Run the following script which uses duplicity [2]:
    BACKUP_FOLDER=/home/your_username/backup
    SOURCE_FOLDER=/media/data/content
    FULL_BACKUP_INTERVAL=2W
     
    echo "Mounting backup folder: $BACKUP_FOLDER"
    mount $BACKUP_FOLDER
     
    echo "Sleeping for a few seconds."
    sleep 3
     
    echo "Backing up: $SOURCE_FOLDER"
    COMMAND="duplicity --full-if-older-than $FULL_BACKUP_INTERVAL $SOURCE_FOLDER file://$BACKUP_FOLDER"
    $COMMAND
     
    echo "Sleeping for a few seconds."
    sleep 3
     
    echo "Unmounting backup folder: $BACKUP_FOLDER"
    umount $BACKUP_FOLDER
VN:F [1.9.22_1171]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)

Leave a Reply