BlogBlog ÜbersichtjailscriptportsoptFreeBSDLinksThermoskanne

Verschlüsselte Backups erzeugen

Mit Hilfe von duplicity lassen sich durch GnuPG verschlüsselte inkrementelle Backups erzeugen, welche sich nach dem Erzeugen auf einen anderen Rechner kopieren lassen. Im FreeBSD Portbaum findet man duplicity unter sysutils/duplicity:

# cd /usr/ports/sysutils/duplicity && make install clean

Im folgenden Beispiel wird /home in den Ordner backup gesichert. Ist noch kein Backup in diesem Ordner vorhanden, wird ein vollständiges Backup erstellt. Als erstes muss ein Passwort gewählt werden, welches für die Verschlüsselung des Backups verwendet wird:

# duplicity /home/ file://backup
Last full backup date: none
GnuPG passphrase:
No signatures found, switching to full backup.
Retype passphrase to confirm:
--------------[ Backup Statistics ]--------------
StartTime 1240000061.53 (Fri Apr 17 22:27:41 2009)
EndTime 1240000065.80 (Fri Apr 17 22:27:45 2009)
ElapsedTime 4.27 (4.27 seconds)
SourceFiles 0
SourceFileSize 23232967 (22.2 MB)
NewFiles 0
NewFileSize 0 (0 bytes)
DeletedFiles 0
ChangedFiles 0
ChangedFileSize 0 (0 bytes)
ChangedDeltaSize 0 (0 bytes)
DeltaEntries 0
RawDeltaSize 23158201 (22.1 MB)
TotalDestinationSizeChange 13929125 (13.3 MB)
Errors 0

Wird das Backup nochmals ausgeführt, werden nur noch die Änderungen gesichert:

# duplicity /home/ file://backup
Last full backup date: Fri Apr 17 22:27:37 2009
GnuPG passphrase:
--------------[ Backup Statistics ]--------------
StartTime 1240000195.98 (Fri Apr 17 22:29:55 2009)
EndTime 1240000200.50 (Fri Apr 17 22:30:00 2009)
ElapsedTime 4.53 (4.53 seconds)
SourceFiles 884
SourceFileSize 28935728 (27.6 MB)
NewFiles 0
NewFileSize 0 (0 bytes)
DeletedFiles 0
ChangedFiles 0
ChangedFileSize 0 (0 bytes)
ChangedDeltaSize 0 (0 bytes)
DeltaEntries 0
RawDeltaSize 4983670 (4.75 MB)
TotalDestinationSizeChange 1738528 (1.66 MB)
Errors 0

Möchte man das Backup gleich per scp auf einen anderen Rechner kopieren, so kann dies wie folgt angegeben werden:

# duplicity /home scp://<Benutzer>@<Rechner>/<Verzeichnis>

Möchte man überprüfen, welche Backups vorhanden sind, kann dazu die collection-status Option von duplicity verwendet werden:

# duplicity collection-status file://backup
Last full backup date: Fri Apr 17 22:27:37 2009
Collection Status
-----------------
Connecting with backend: LocalBackend
Archive dir: None
 
Found 0 backup chains without signatures.
 
Found a complete backup chain with matching signature chain:
-------------------------
Chain start time: Fri Apr 17 22:27:37 2009
Chain end time: Fri Apr 17 22:29:53 2009
Number of contained backup sets: 2
Total number of contained volumes: 2
 Type of backup set:                            Time:      Num volumes:
                Full         Fri Apr 17 22:27:37 2009                 1
         Incremental         Fri Apr 17 22:29:53 2009                 1
-------------------------
No orphaned or incomplete backup sets found.

Mit list-current-files werden alle Dateien, welche im Backup vorhanden sind, aufgelistet:

#  duplicity list-current-files file://backup
Last full backup date: Fri Apr 17 22:27:37 2009
GnuPG passphrase:
Fri Apr 17 22:29:38 2009 .
[..]

Durch verify kann der Inhalt des Backups mir dem Quellordner verglichen werden:

# duplicity verify file://backup /home
Last full backup date: Fri Apr 17 22:27:37 2009
GnuPG passphrase:
Difference found: File . has mtime Fri Apr 17 22:35:34 2009, expected Fri Apr 17 22:29:38 2009
Error accessing possibly locked file /home/test/.qt/.qt_plugins_3.3rc.lock
Difference found: File test is missing
Difference found: File test/bla is missing
[...]

Mit der Zeit können ältere Backups entfernt werden, dazu kann ein Datum mit remove-older-than angegeben werden und alle ältere Backups werden gelöscht:

# duplicity remove-older-than 2009-04-18 file://backup

Soll der Inhalt des Backups wiederhergestellt werden, so kann dies wie folgt gemacht werden:

# duplicity file://backup /tmp/restore
Last full backup date: Fri Apr 17 22:27:37 2009
GnuPG passphrase: 
[...]

Mehr Informationen und alle Optionen von duplicity findet man in der Manpage duplicity(1).

Comments (1)  Permalink