Duply/Anwendung: Unterschied zwischen den Versionen
Aus Foxwiki
K Textersetzung - „line>“ durch „line copy>“ |
Keine Bearbeitungszusammenfassung |
||
| Zeile 1: | Zeile 1: | ||
=== Besachreibung === | === Besachreibung === | ||
; Anwendung | ; Anwendung | ||
; Erstmalige Verwendung (Profilerstellung) | ; Erstmalige Verwendung (Profilerstellung) | ||
<syntaxhighlight lang="bash" highlight="1" line copy> | <syntaxhighlight lang="bash" highlight="1" line copy> | ||
| Zeile 18: | Zeile 17: | ||
; Alle conf-Parameter können stattdessen auch in der Umgebung definiert werden | ; Alle conf-Parameter können stattdessen auch in der Umgebung definiert werden | ||
=== Pre- und Post-Skripte === | === Pre- und Post-Skripte === | ||
| Zeile 77: | Zeile 75: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
$ '''duply | $ '''duply datenSystem create | ||
don't forget to edit this new conf file | don't forget to edit this new conf file | ||
==== backup ' | ==== backup 'datenSystem' now ==== | ||
<syntaxhighlight lang="bash" highlight="1" line copy> | <syntaxhighlight lang="bash" highlight="1" line copy> | ||
</syntaxhighlight> | </syntaxhighlight> | ||
$ '''duply | $ '''duply datenSystem backup''' | ||
==== available backup sets ==== | ==== available backup sets ==== | ||
| Zeile 90: | Zeile 88: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
list available backup sets of profile ' | list available backup sets of profile 'datenSystem' | ||
<syntaxhighlight lang="bash" highlight="1" line copy> | <syntaxhighlight lang="bash" highlight="1" line copy> | ||
</syntaxhighlight> | </syntaxhighlight> | ||
$ '''duply | $ '''duply datenSystem status''' | ||
==== outdated backups ==== | ==== outdated backups ==== | ||
; list and delete outdated backups of ' | ; list and delete outdated backups of 'datenSystem' | ||
<syntaxhighlight lang="bash" highlight="1" line copy> | <syntaxhighlight lang="bash" highlight="1" line copy> | ||
</syntaxhighlight> | </syntaxhighlight> | ||
$ '''duply | $ '''duply datenSystem purge --force''' | ||
==== restore ==== | ==== restore ==== | ||
; restore latest backup of ' | ; restore latest backup of 'datenSystem' to /mnt/restore | ||
<syntaxhighlight lang="bash" highlight="1" line copy> | <syntaxhighlight lang="bash" highlight="1" line copy> | ||
</syntaxhighlight> | </syntaxhighlight> | ||
$ '''duply | $ '''duply datenSystem restore /mnt/restore''' | ||
; restore /etc/passwd of ' | ; restore /etc/passwd of 'datenSystem' from 4 days ago to /root/pw | ||
<syntaxhighlight lang="bash" highlight="1" line copy> | <syntaxhighlight lang="bash" highlight="1" line copy> | ||
</syntaxhighlight> | </syntaxhighlight> | ||
$ '''duply | $ '''duply datenSystem fetch etc/passwd /root/pw 4D''' | ||
$ '''(see "duplicity manpage", section TIME FORMATS)''' | $ '''(see "duplicity manpage", section TIME FORMATS)''' | ||
==== a one line batch job on ' | ==== a one line batch job on 'datenSystem' for cron execution ==== | ||
<syntaxhighlight lang="bash" highlight="1" line copy> | <syntaxhighlight lang="bash" highlight="1" line copy> | ||
</syntaxhighlight> | </syntaxhighlight> | ||
$ '''duply | $ '''duply datenSystem backup_verify_purge --force''' | ||
==== batch job to run a full backup with pre/post scripts ==== | ==== batch job to run a full backup with pre/post scripts ==== | ||
| Zeile 127: | Zeile 125: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
$ '''duply | $ '''duply datenSystem pre_full_post''' | ||
=== Problembehebung === | === Problembehebung === | ||
Version vom 20. September 2026, 19:41 Uhr
Besachreibung
- Anwendung
- Erstmalige Verwendung (Profilerstellung)
duply <Profil> erstellen
- Verwendung im Einzel- oder Batch-Modus
duply <profile> <Befehl>[[_|+|-]<Befehl>[_|+|-]...] [<Optionen> ...]
- Für Stapel können die bedingten Trennzeichen auch als Pseudo-Befehle geschrieben werden und(+), oder(-)
- siehe BEISPIELE
- siehe SEPARATORS
Nicht duply-Optionen werden an duplicity weitergegeben
- siehe OPTIONS
- Alle conf-Parameter können stattdessen auch in der Umgebung definiert werden
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 datenSystem create
don't forget to edit this new conf file
backup 'datenSystem' now
$ duply datenSystem backup
available backup sets
list available backup sets of profile 'datenSystem'
$ duply datenSystem status
outdated backups
- list and delete outdated backups of 'datenSystem'
$ duply datenSystem purge --force
restore
- restore latest backup of 'datenSystem' to /mnt/restore
$ duply datenSystem restore /mnt/restore
- restore /etc/passwd of 'datenSystem' from 4 days ago to /root/pw
$ duply datenSystem fetch etc/passwd /root/pw 4D $ (see "duplicity manpage", section TIME FORMATS)
a one line batch job on 'datenSystem' for cron execution
$ duply datenSystem backup_verify_purge --force
batch job to run a full backup with pre/post scripts
$ duply datenSystem 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