adminsys:script-save-auto-borg-vps
no way to compare when less than two revisions
Différences
Ci-dessous, les différences entre deux révisions de la page.
— | adminsys:script-save-auto-borg-vps [2019/02/25 16:09] (Version actuelle) – créée jaxom | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
+ | <file bash Auto-BorgBackup-VPS.sh> | ||
+ | #!/bin/bash | ||
+ | ## Sauvegarde distante du VPS via un Borg local ## | ||
+ | # Auteur : Jaxom < | ||
+ | # Credits to https:// | ||
+ | # and https:// | ||
+ | # Repo initialement créé avec "borg init --encryption=repokey / | ||
+ | # Arrêt du rsync quotidien, pas de données critiques. | ||
+ | # Appel hebdomadaire par Cron. | ||
+ | |||
+ | ## Suivi ## | ||
+ | # 19-02-25 mise en place. | ||
+ | |||
+ | # | ||
+ | user="" | ||
+ | pass="" | ||
+ | |||
+ | ## AUTO Part ## | ||
+ | #From @djib https:// | ||
+ | #Modified by @jaxom on 2018-12-19 | ||
+ | #Licenced under GPL. https:// | ||
+ | |||
+ | #GOAL: Creates a backup and removes some of the previous backups | ||
+ | #HOWTO: call it via cron as frequently as you want | ||
+ | |||
+ | |||
+ | # Backups are created with the following prefix | ||
+ | PREFIX=" | ||
+ | # All backups with the previous prefix are deleted except the following dates | ||
+ | TODAY=`date ' | ||
+ | LAST_WEEK=`date -d "7 days ago" ' | ||
+ | BEGINNING_OF_MONTH=`date ' | ||
+ | BEGINNING_OF_LAST_MONTH=`date -d "last month" ' | ||
+ | |||
+ | #separation between apps and config | ||
+ | |||
+ | yunohost backup create -n $PREFIX$TODAY-core --system | ||
+ | yunohost backup create -n $PREFIX$TODAY-apps --apps | ||
+ | |||
+ | #Removal of old backups | ||
+ | cd / | ||
+ | rm `ls | grep $PREFIX | grep -v " | ||
+ | |||
+ | |||
+ | #Send an SMS notification using FreeMobileAPI | ||
+ | #curl --insecure " | ||
+ | |||
+ | ## BORG Part ## | ||
+ | |||
+ | # the envvar $REPONAME is something you should just hardcode | ||
+ | export REPOSITORY="/ | ||
+ | # Fill in your password file here, borg picks it up automatically | ||
+ | # | ||
+ | #export BORG_PASSCOMMAND=" | ||
+ | export BORG_PASSPHRASE="" | ||
+ | |||
+ | |||
+ | # Dossier à sauvegarder | ||
+ | DossierLocal=$REPOSITORY | ||
+ | #Dossier de sauvegarde sur le NAS | ||
+ | DossierDistant=/ | ||
+ | |||
+ | #Créer une sauvegarde | ||
+ | borg create $REPOSITORY:: | ||
+ | |||
+ | # Reset en cas d' | ||
+ | if [ " | ||
+ | export BORG_PASSPHRASE="" | ||
+ | exit 1 | ||
+ | fi | ||
+ | |||
+ | #Pruner le repo | ||
+ | borg prune -v --list --stats --keep-daily=7 --keep-weekly=4 --keep-monthly=-1 $REPOSITORY | ||
+ | |||
+ | # | ||
+ | rsync -azPvH --delete-during --bwlimit=2.1m $DossierLocal admin@cloudherve.myqnapcloud.com: | ||
+ | |||
+ | |||
+ | #Confirmer par SMS | ||
+ | message=" | ||
+ | curl -s -i -k " | ||
+ | |||
+ | # Reset le password Borg | ||
+ | #export BORG_PASSCOMMAND="" | ||
+ | export BORG_PASSPHRASE="" | ||
+ | exit 0 | ||
+ | |||
+ | |||
+ | </ |
adminsys/script-save-auto-borg-vps.txt · Dernière modification : 2019/02/25 16:09 de jaxom