Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • S scripts
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • Deployments
    • Deployments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • Repository
  • Wiki
    • Wiki
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • rizzle
  • scripts
  • Wiki
  • Tutorials
  • backup duplicity

Last edited by rizzle Apr 05, 2019
Page history

backup duplicity

Create the gpg key

First you have to create a gpg key for generating the backups. Either you generate a key without passphrase to allow for automatic backups or you specify the passphrase on the command line when running backups.

Key without passphrase

Generate the key:

$ gpg --quick-gen-key --passphrase "" backup

To export the key to a file first list the keys:

$ gpg -K

Then export the one you want with:

$ gpg --export $KEYID >/tmp/key.export

This can then be imported on the target machine via:

gpg --import  </tmp/key.export

Key with passphrase

Same as above but without the --passphrase part.

Create the backup

Create the batch file for the backup.

#!/bin/bash

TARGET='rsync://backup@$DOMAIN/$PATH'

KEY='--encrypt-key $key'

# create the backup, incrementally and a full one every month
duplicity incr --full-if-older-than 1M --name "$name" "$KEY" "$path" "${TARGET}/${sub_folder}"

# remove backups older than 3 months
PASSPHRASE="" duplicity remove-older-than 3M --force "$KEY" "${TARGET}/${sub_folder}"

If you have a passphrase for the gpg key, provide it as an environment variable to duplicity.

Variable Function
$name The name of the backup, prefixed to the generated file
$path The path to backup
$sub_folder The sub folder where to store this on the backup machine

To have an rsync server as above and only allow rsync login follow the guide in Rsync only SSH.

Clone repository
  • Home
  • small howtos
  • tutorials
  • tutorials
    • backup duplicity
    • multi storage server
    • multiple ssid hostapd
    • openwrt on nfs root
    • po documention
    • pxe server
    • rsync only ssh
    • tinc
    • vp9 conversion