Duply/Anwendung: Unterschied zwischen den Versionen
Erscheinungsbild
	
	
K Textersetzung - „line>“ durch „line copy>“  | 
				|||
| (2 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt) | |||
| Zeile 3: | Zeile 3: | ||
<!--  | <!--  | ||
; Erstmalige Verwendung (Profilerstellung)  | ; Erstmalige Verwendung (Profilerstellung)  | ||
<syntaxhighlight lang="bash" highlight="1" line>  | <syntaxhighlight lang="bash" highlight="1" line copy>  | ||
duply <Profil> erstellen  | duply <Profil> erstellen  | ||
</syntaxhighlight>  | </syntaxhighlight>  | ||
| Zeile 30: | Zeile 30: | ||
; pre-Datei  | ; pre-Datei  | ||
<syntaxhighlight lang="bash" highlight="1" line>  | <syntaxhighlight lang="bash" highlight="1" line copy>  | ||
</syntaxhighlight>  | </syntaxhighlight>  | ||
| Zeile 56: | Zeile 56: | ||
* Zudem erlaubt duply die Verwendung von Wildcards  | * Zudem erlaubt duply die Verwendung von Wildcards  | ||
* Die hier dargestellte <tt>exclude</tt> Datei sichert die Verzeichnisse <tt>/etc/, /root/, /var/www/</tt> und exkludiert alle anderen Verzeichnisse  | * Die hier dargestellte <tt>exclude</tt> Datei sichert die Verzeichnisse <tt>/etc/, /root/, /var/www/</tt> und exkludiert alle anderen Verzeichnisse  | ||
<syntaxhighlight lang="bash" highlight="1" line>  | <syntaxhighlight lang="bash" highlight="1" line copy>  | ||
</syntaxhighlight>  | </syntaxhighlight>  | ||
| Zeile 71: | Zeile 71: | ||
* Backups welche die <tt>MAX_AGE</tt> überschritten haben werden mit <tt>purge</tt> angezeigt und durch die zusätzliche Option <tt>--force</tt> gelöscht  | * Backups welche die <tt>MAX_AGE</tt> überschritten haben werden mit <tt>purge</tt> angezeigt und durch die zusätzliche Option <tt>--force</tt> gelöscht  | ||
* Der Befehl <tt>/usr/bin/duply /root/.duply/test incr</tt> führt ein inkrementelles Backup aus  | * Der Befehl <tt>/usr/bin/duply /root/.duply/test incr</tt> führt ein inkrementelles Backup aus  | ||
=== Beispiele ===  | === Beispiele ===  | ||
==== Profil erstellen ====  | ==== Profil erstellen ====  | ||
<syntaxhighlight lang="bash" highlight="1" line>  | <syntaxhighlight lang="bash" highlight="1" line copy>  | ||
</syntaxhighlight>  | </syntaxhighlight>  | ||
| Zeile 96: | Zeile 81: | ||
==== backup 'humbug' now ====  | ==== backup 'humbug' now ====  | ||
<syntaxhighlight lang="bash" highlight="1" line>  | <syntaxhighlight lang="bash" highlight="1" line copy>  | ||
</syntaxhighlight>  | </syntaxhighlight>  | ||
| Zeile 102: | Zeile 87: | ||
==== available backup sets ====  | ==== available backup sets ====  | ||
<syntaxhighlight lang="bash" highlight="1" line>  | <syntaxhighlight lang="bash" highlight="1" line copy>  | ||
</syntaxhighlight>  | </syntaxhighlight>  | ||
list available backup sets of profile 'humbug'  | list available backup sets of profile 'humbug'  | ||
<syntaxhighlight lang="bash" highlight="1" line>  | <syntaxhighlight lang="bash" highlight="1" line copy>  | ||
</syntaxhighlight>  | </syntaxhighlight>  | ||
| Zeile 113: | Zeile 98: | ||
==== outdated backups ====  | ==== outdated backups ====  | ||
; list and delete outdated backups of 'humbug'  | ; list and delete outdated backups of 'humbug'  | ||
<syntaxhighlight lang="bash" highlight="1" line>  | <syntaxhighlight lang="bash" highlight="1" line copy>  | ||
</syntaxhighlight>  | </syntaxhighlight>  | ||
| Zeile 120: | Zeile 105: | ||
==== restore ====  | ==== restore ====  | ||
; restore latest backup of 'humbug' to /mnt/restore  | ; restore latest backup of 'humbug' to /mnt/restore  | ||
<syntaxhighlight lang="bash" highlight="1" line>  | <syntaxhighlight lang="bash" highlight="1" line copy>  | ||
</syntaxhighlight>  | </syntaxhighlight>  | ||
| Zeile 126: | Zeile 111: | ||
; restore /etc/passwd of 'humbug' from 4 days ago to /root/pw  | ; restore /etc/passwd of 'humbug' from 4 days ago to /root/pw  | ||
<syntaxhighlight lang="bash" highlight="1" line>  | <syntaxhighlight lang="bash" highlight="1" line copy>  | ||
</syntaxhighlight>  | </syntaxhighlight>  | ||
| Zeile 133: | Zeile 118: | ||
==== a one line batch job on 'humbug' for cron execution ====  | ==== a one line batch job on 'humbug' for cron execution ====  | ||
<syntaxhighlight lang="bash" highlight="1" line>  | <syntaxhighlight lang="bash" highlight="1" line copy>  | ||
</syntaxhighlight>  | </syntaxhighlight>  | ||
| Zeile 139: | Zeile 124: | ||
==== batch job to run a full backup with pre/post scripts ====  | ==== batch job to run a full backup with pre/post scripts ====  | ||
<syntaxhighlight lang="bash" highlight="1" line>  | <syntaxhighlight lang="bash" highlight="1" line copy>  | ||
</syntaxhighlight>  | </syntaxhighlight>  | ||
| Zeile 147: | Zeile 132: | ||
==== Volume was signed by key ''X'' not ''Y'' ====  | ==== Volume was signed by key ''X'' not ''Y'' ====  | ||
==== OSError: Socket is closed ====  | ==== OSError: Socket is closed ====  | ||
<syntaxhighlight lang="bash" highlight="1" line>  | <syntaxhighlight lang="bash" highlight="1" line copy>  | ||
</syntaxhighlight>  | </syntaxhighlight>  | ||
| Zeile 165: | Zeile 150: | ||
* OSError: Socket is closed  | * OSError: Socket is closed  | ||
[[Kategorie:  | [[Kategorie:duply]]  | ||
Aktuelle Version vom 11. Mai 2025, 12:45 Uhr
Besachreibung
- Anwendung
 
Pre- und Post-Skripte
- Das pre-Skript wird direkt vor dem Backup ausgeführt, das post-Skript direkt nach dem Backup
 - Mit diesen Skripten können beispielsweise Snapshots von LVM-Volumes oder Dumps von SQL Datenbanken gemacht und in das Backup einbezogen werden
 - Die files pre und post müssen im jeweiligen duply Verzeichnis liegen (Bsp.: /home/user/.duply/backup/) und ausführbar sein
 - Werden die pre/post Scripte nicht wie erhofft ausgeführt (beispielsweise bei den Sicherchungs-Methoden "full/incr"), können diese explizit angegeben werden: pre_incr_post
 
- Beispiel
 
Hier ein Beispiel für ein PRE/POST Skript welches vor dem Backup einen SQL-Dump aller Datenbanken erstellt und diesen nach dem Backup wieder löscht
- pre-Datei
 
/usr/bin/mysqldump --all-databases -u root -ppw > /tmp/sqldump-$(date '+%F')
- post-Datei
 
/bin/rm /tmp/sqldump-$(date '+%F')
- PRE/POST SCRIPTS
 
Useful internal duply variables are exported to the scripts
PROFILE, CONFDIR, SOURCE, TARGET_URL_<PROT|HOSTPATH|USER|PASS>, GnuPG_<KEYS_ENC|KEY_SIGN|PW>, CMD_ERR, RUN_START, CMD_<PREV|NEXT> (previous/next command), CND_<PREV|NEXT> (condition before/after)
The CMD_* variables were introduced to allow different actions according to the command the scripts were attached to e.g. 'pre_bkp_post_pre_verify_post' will call the pre script two times, with CMD_NEXT variable set to 'bkp' on the first and to 'verify' on the second run
- CMD_ERR holds the exit code of the CMD_PREV
 
exclude
- duply arbeitet standardmäßig mit einer Whitelist
 - Um gewisse Verzeichnisse oder Dateien von einem Backup zu inkludieren muss die Datei exclude im duply Verzeichnis erstellt werden
 - Die Syntax erlaubt das Hinzufügen von Verzeichnissen und Dateien mit einem + /pfad/zur/datei
 - Um ein Verzeichnis zu exkludieren muss in der exclude ein - /pfad/zum/Verzeichnis eingefügt werden
 - Zudem erlaubt duply die Verwendung von Wildcards
 - Die hier dargestellte exclude Datei sichert die Verzeichnisse /etc/, /root/, /var/www/ und exkludiert alle anderen Verzeichnisse
 
+ /etc/ + /root/ + /var/www/ - **
Argumente
- duply bietet eine Vielzahl von Kommandozeilenparametern für die Sicherung und Wiederherstellung von Daten
 - Die gesamte Liste ist in der Manpage von duply zu finden
 - Beim Einsatz von mehreren Parameter werden diese durch einen Unterstrich (_) getrennt
 - Mit /usr/bin/duply /root/.duply/test full_verify_purge --force wird ein volles Backup erstellt, verifiziert und alte Backups gelöscht
 - Backups welche die MAX_AGE überschritten haben werden mit purge angezeigt und durch die zusätzliche Option --force gelöscht
 - Der Befehl /usr/bin/duply /root/.duply/test incr führt ein inkrementelles Backup aus
 
Beispiele
Profil erstellen
$ duply humbug create
don't forget to edit this new conf file
backup 'humbug' now
$ duply humbug backup
available backup sets
list available backup sets of profile 'humbug'
$ duply humbug status
outdated backups
- list and delete outdated backups of 'humbug'
 
$ duply humbug purge --force
restore
- restore latest backup of 'humbug' to /mnt/restore
 
$ duply humbug restore /mnt/restore
- restore /etc/passwd of 'humbug' from 4 days ago to /root/pw
 
$ duply humbug fetch etc/passwd /root/pw 4D $ (see "duplicity manpage", section TIME FORMATS)
a one line batch job on 'humbug' for cron execution
$ duply humbug backup_verify_purge --force
batch job to run a full backup with pre/post scripts
$ duply humbug pre_full_post
Problembehebung
Volume was signed by key X not Y
OSError: Socket is closed
ssh: Exception (client): Signature verification (ssh-rsa) failed ssh: Traceback (most recent call last): ssh: File "/usr/local/lib/python3.10/dist-packages/paramiko/transport.py", line 2130, in run ssh: self.kex_engine.parse_next(ptype, m) ssh: File "/usr/local/lib/python3.10/dist-packages/paramiko/kex_curve25519.py", line 64, in parse_next ssh: return self._parse_kexecdh_reply(m) ssh: File "/usr/local/lib/python3.10/dist-packages/paramiko/kex_curve25519.py", line 130, in _parse_kexecdh_reply ssh: self.transport._verify_key(peer_host_key_bytes, sig) ssh: File "/usr/local/lib/python3.10/dist-packages/paramiko/transport.py", line 1942, in _verify_key ssh: raise SSHException( ssh: paramiko.ssh_exception.SSHException: Signature verification (ssh-rsa) failed ssh: Attempt of put Nr. 1 failed
- OSError: Socket is closed