From 228969dc8147bcda94caf89264630cb32ea1310a Mon Sep 17 00:00:00 2001 From: Tykayn Date: Mon, 28 Nov 2022 11:07:00 +0100 Subject: [PATCH] add proxmox scripts --- .../rise/get_to_juvisy_rise_backups.sh | 1 + bash/backups/rise/mastodon_borg.sh | 4 +- bash/backups/rise/peertube_borg.sh | 13 ++++-- bash/backups/rise/promox_config.sh | 42 +++++++++++++++++++ bash/backups/rise/tksites_borg.sh | 15 ++++--- 5 files changed, 64 insertions(+), 11 deletions(-) create mode 100644 bash/backups/rise/promox_config.sh diff --git a/bash/backups/rise/get_to_juvisy_rise_backups.sh b/bash/backups/rise/get_to_juvisy_rise_backups.sh index c7ad7414..b0ae09c4 100644 --- a/bash/backups/rise/get_to_juvisy_rise_backups.sh +++ b/bash/backups/rise/get_to_juvisy_rise_backups.sh @@ -1,3 +1,4 @@ #!/bin/bash +# récupérer tous les borg backup de conteneurs de Rise rsync tykayn@proxmox.coussinet.org:/poule/encrypted/* /media/tykayn/disque_usb/backup_rise/encrypted -avzP diff --git a/bash/backups/rise/mastodon_borg.sh b/bash/backups/rise/mastodon_borg.sh index 76c24f0c..3a6eda0d 100644 --- a/bash/backups/rise/mastodon_borg.sh +++ b/bash/backups/rise/mastodon_borg.sh @@ -27,10 +27,10 @@ echo "### ${today} start backup script " | tee -a $LOG_FILE_BACKUP 2>&1 # ====================== creation de borg backup echo ' ' >> $LOG_FILE_BACKUP -echo "### ${today} | SOYOUSTART | start backup script soyoustart_borg.sh " | tee -a $LOG_FILE_BACKUP 2>&1 +echo "### ${today} | RISE | start backup script tksites_borg.sh " | tee -a $LOG_FILE_BACKUP 2>&1 borg create $BORG_FOLDER_RISE::soyoustart_{user}-{now} $MASTODON_FOLDER_RISE --exclude '.bundler/gems' --exclude 'node_modules' --exclude '/home/mastodon/live/public/system/cache/*' --stats --progress --verbose --stats --compression zlib,9 | tee -a $LOG_FILE_BACKUP 2>&1 # ====================== nettoyage - borg prune -v --list --stats --keep-daily=6 --keep-weekly=4 --keep-monthly=3 --keep-yearly=2 /$BORG_FOLDER_SOYOUSTART | tee -a $LOG_FILE_BACKUP 2>&1 + borg prune -v --list --stats --keep-daily=6 --keep-weekly=4 --keep-monthly=3 --keep-yearly=2 $BORG_FOLDER_RISE | tee -a $LOG_FILE_BACKUP 2>&1 echo "### ${date} | SOYOUSTART | done borg_spaceship.sh " | tee -a $LOG_FILE_BACKUP 2>&1 diff --git a/bash/backups/rise/peertube_borg.sh b/bash/backups/rise/peertube_borg.sh index f54344ab..b3395dbb 100644 --- a/bash/backups/rise/peertube_borg.sh +++ b/bash/backups/rise/peertube_borg.sh @@ -11,7 +11,12 @@ # today=$(date +"%Y-%m-%d_%H-%I-%S") LOG_FILE_BACKUP=/poule/encrypted/log_backup_rise.log +# destination BORG_FOLDER_RISE=/poule/encrypted/peertube + +# sources +NGINX_FOLDER_RISE=/poule/subvol-101-disk-0/etc/nginx +LETSENCRYPT_FOLDER_RISE=/poule/subvol-101-disk-0/etc/letsencrypt PEERTUBE_FOLDER_RISE=/poule/subvol-101-disk-0/var/www/peertube export BORG_PASSCOMMAND="cat /root/.borg-passphrase" @@ -27,10 +32,10 @@ echo "### ${today} start backup script " | tee -a $LOG_FILE_BACKUP 2>&1 # ====================== creation de borg backup echo ' ' >> $LOG_FILE_BACKUP -echo "### ${today} | SOYOUSTART | start backup script soyoustart_borg.sh " | tee -a $LOG_FILE_BACKUP 2>&1 +echo "### ${today} | RISE | start backup script peertube_borg.sh " | tee -a $LOG_FILE_BACKUP 2>&1 - borg create $BORG_FOLDER_RISE::soyoustart_{user}-{now} $PEERTUBE_FOLDER_RISE --exclude '.bundler/gems' --exclude 'node_modules' --progress --verbose --stats --compression zlib,9 | tee -a $LOG_FILE_BACKUP 2>&1 + borg create $BORG_FOLDER_RISE::soyoustart_{user}-{now} $PEERTUBE_FOLDER_RISE $NGINX_FOLDER_RISE $LETSENCRYPT_FOLDER_RISE --exclude '.bundler/gems' --exclude 'node_modules' --progress --verbose --stats --compression zlib,9 | tee -a $LOG_FILE_BACKUP 2>&1 # ====================== nettoyage - borg prune -v --list --stats --keep-daily=6 --keep-weekly=4 --keep-monthly=3 --keep-yearly=2 /$BORG_FOLDER_SOYOUSTART | tee -a $LOG_FILE_BACKUP 2>&1 + borg prune -v --list --stats --keep-daily=6 --keep-weekly=4 --keep-monthly=3 --keep-yearly=2 $BORG_FOLDER_RISE | tee -a $LOG_FILE_BACKUP 2>&1 -echo "### ${date} | SOYOUSTART | done borg_spaceship.sh " | tee -a $LOG_FILE_BACKUP 2>&1 +echo "### ${date} | RISE | done peertube_borg.sh " | tee -a $LOG_FILE_BACKUP 2>&1 diff --git a/bash/backups/rise/promox_config.sh b/bash/backups/rise/promox_config.sh new file mode 100644 index 00000000..5985efd8 --- /dev/null +++ b/bash/backups/rise/promox_config.sh @@ -0,0 +1,42 @@ +#!/bin/bash +# ------------- pour créer le dépot borg: +# borg init --encryption=repokey-blake2 /poule/encrypted/proxmox +# ------------- ajouter dans la crontab root +# sudo crontab -e +# # lancer toutes les 4 heures le script de création borg +# 0 */4 * * * bash /poule/encrypted/proxmox_borg.sh +# +# ------------- +# config +# +today=$(date +"%Y-%m-%d_%H-%I-%S") +LOG_FILE_BACKUP=/poule/encrypted/log_backup_rise.log + +# destination +BORG_FOLDER_RISE=/poule/encrypted/proxmox + +# sources +PROXMOX_CONF_FOLDER_RISE=/etc/pve +NGINX_FOLDER_RISE=/etc/nginx +LETSENCRYPT_FOLDER_RISE=/etc/letsencrypt + +export BORG_PASSCOMMAND="cat /root/.borg-passphrase" +# ====================== dossiers a sauvegarder ====================== +# les bases de données sont sauvegardées avec automysqlbackup et autopostgresqlbackup +# les fichiers des sites web +# la config nginx + +NGINX_FOLDER=/etc/nginx + +echo ' ' >> $LOG_FILE_BACKUP +echo "### ${today} start backup script " | tee -a $LOG_FILE_BACKUP 2>&1 + +# ====================== creation de borg backup +echo ' ' >> $LOG_FILE_BACKUP +echo "### ${today} | RISE | start backup script proxmox_borg.sh " | tee -a $LOG_FILE_BACKUP 2>&1 + + borg create $BORG_FOLDER_RISE::soyoustart_{user}-{now} $PROXMOX_CONF_FOLDER_RISE $NGINX_FOLDER_RISE $LETSENCRYPT_FOLDER_RISE --stats --progress --verbose --stats --compression zlib,9 | tee -a $LOG_FILE_BACKUP 2>&1 +# ====================== nettoyage + borg prune -v --list --stats --keep-daily=6 --keep-weekly=4 --keep-monthly=3 --keep-yearly=2 $BORG_FOLDER_RISE | tee -a $LOG_FILE_BACKUP 2>&1 + +echo "### ${date} | RISE | done proxmox_borg.sh " | tee -a $LOG_FILE_BACKUP 2>&1 diff --git a/bash/backups/rise/tksites_borg.sh b/bash/backups/rise/tksites_borg.sh index 1d3a3c5c..3f99b820 100644 --- a/bash/backups/rise/tksites_borg.sh +++ b/bash/backups/rise/tksites_borg.sh @@ -11,9 +11,14 @@ # today=$(date +"%Y-%m-%d_%H-%I-%S") LOG_FILE_BACKUP=/poule/encrypted/log_backup_rise.log -BORG_FOLDER_RISE=/poule/encrypted/peertube + +# destination +BORG_FOLDER_RISE=/poule/encrypted/tksites + +# sources TKSITES_FOLDER_RISE=/poule/subvol-103-disk-0/home/www NGINX_FOLDER_RISE=/poule/subvol-103-disk-0/etc/nginx +LETSENCRYPT_FOLDER_RISE=/poule/subvol-103-disk-0/etc/letsencrypt AUTOMYSQLBACKUP_FOLDER_RISE=/poule/subvol-103-disk-0/etc/automysqlbackup export BORG_PASSCOMMAND="cat /root/.borg-passphrase" @@ -29,10 +34,10 @@ echo "### ${today} start backup script " | tee -a $LOG_FILE_BACKUP 2>&1 # ====================== creation de borg backup echo ' ' >> $LOG_FILE_BACKUP -echo "### ${today} | SOYOUSTART | start backup script soyoustart_borg.sh " | tee -a $LOG_FILE_BACKUP 2>&1 +echo "### ${today} | RISE | start backup script soyoustart_borg.sh " | tee -a $LOG_FILE_BACKUP 2>&1 - borg create $BORG_FOLDER_RISE::soyoustart_{user}-{now} $TKSITES_FOLDER_RISE $NGINX_FOLDER_RISE $AUTOMYSQLBACKUP_FOLDER_RISE --exclude '.bundler/gems' --exclude 'node_modules' --progress --verbose --stats --compression zlib,9 | tee -a $LOG_FILE_BACKUP 2>&1 + borg create $BORG_FOLDER_RISE::soyoustart_{user}-{now} $TKSITES_FOLDER_RISE $NGINX_FOLDER_RISE $AUTOMYSQLBACKUP_FOLDER_RISE $LETSENCRYPT_FOLDER_RISE --exclude '.bundler/gems' --exclude 'node_modules' --progress --verbose --stats --compression zlib,9 | tee -a $LOG_FILE_BACKUP 2>&1 # ====================== nettoyage - borg prune -v --list --stats --keep-daily=6 --keep-weekly=4 --keep-monthly=3 --keep-yearly=2 /$BORG_FOLDER_SOYOUSTART | tee -a $LOG_FILE_BACKUP 2>&1 + borg prune -v --list --stats --keep-daily=6 --keep-weekly=4 --keep-monthly=3 --keep-yearly=2 $BORG_FOLDER_RISE | tee -a $LOG_FILE_BACKUP 2>&1 -echo "### ${date} | SOYOUSTART | done borg_spaceship.sh " | tee -a $LOG_FILE_BACKUP 2>&1 +echo "### ${date} | RISE | done soyoustart_borg.sh " | tee -a $LOG_FILE_BACKUP 2>&1