scripts/bash/backups

59 lines
1.9 KiB
Plaintext
Raw Normal View History

2023-02-17 11:40:28 +01:00
#/bin/bash
2023-02-17 12:07:58 +01:00
# @author sync_spaceship by @tykayn - contact at cipherbliss.com
2023-02-17 11:40:28 +01:00
#
2023-02-17 12:07:58 +01:00
# disques ext
# - blue 4To
# - brossadent 4To
# - catwoman 4To
# - chaton 5To
# - kouignamann 4To
# - lilia 4To
# - louisbraille 4To
# - monolith 6.2To
# - rondoudou 4To non chiffré
# - Taiga 1To
# configs
export today=`date` # to log current time
export ARCHIVE_CLEAR="/home/poule/encrypted/stockage-syncable" # place where we have our things sorted, other than home
export BORG_PASSCOMMAND="cat $ARCHIVE_CLEAR/.tk-borg-passphrase" # get the borg repo pass
export LOG_FILE_BACKUP="$ARCHIVE_CLEAR/www/backup/log_backup.log"
export LOG_FILE_BACKUP_DATES="$ARCHIVE_CLEAR/www/backup/summary_log_backup.log" # log dates of execution of the script
2023-02-17 11:40:28 +01:00
2023-02-17 12:07:58 +01:00
echo "watch the logs with \n tail -f $LOG_FILE_BACKUP_DATES"
2023-02-17 11:40:28 +01:00
2023-02-17 12:07:58 +01:00
# big disks can replicate the whole ZFS encrypted archives
big_disks=("blue","brossadent","catwoman","chaton","kouignamann","monolith","lilia","louisbraille","monolith")
2023-02-17 11:40:28 +01:00
2023-02-17 12:07:58 +01:00
# clear disk will take medias
clear_disks=("rondoudou")
2023-02-17 11:40:28 +01:00
2023-02-17 12:07:58 +01:00
# small disks will only take borg backups
small_disks=("Taiga")
2023-02-17 11:40:28 +01:00
2023-02-17 12:07:58 +01:00
# déclaration d'une fonction
function syncToBigDiskName()
{
2023-02-17 11:40:28 +01:00
local diskName=$1
2023-02-17 12:07:58 +01:00
echo ' ' >> $LOG_FILE_BACKUP_DATES
echo "### ${today} replicate to disk ${diskName}" >> $LOG_FILE_BACKUP_DATES
2023-02-17 11:40:28 +01:00
2023-02-17 12:07:58 +01:00
# chech that the mounted folder of the disk exists
2023-02-17 11:40:28 +01:00
FILE=/media/$USER/$diskName
2023-02-17 12:07:58 +01:00
if test -d "$FILE"; then
echo "### $FILE exists." >> $LOG_FILE_BACKUP_DATES
# ok to send Rsync of encrypted folder
rsync -avP /home/poule/encrypted/* /media/$USER/$diskName/encrypted --delete --exclude '.npm' --exclude '.yarn' --exclude 'node_modules' --exclude '.mozilla' --delete --exclude '.cache' --exclude 'Cache'
rsync -avP /home/poule/borg_archives/* /media/$USER/$diskName/borg_archives --delete --exclude '.npm' --exclude '.yarn' --exclude 'node_modules' --exclude '.mozilla' --delete --exclude '.cache' --exclude 'Cache'
2023-02-17 11:40:28 +01:00
else
2023-02-17 12:07:58 +01:00
echo "### /!\ - folder not found $FILE"
2023-02-17 11:40:28 +01:00
fi
}
2023-02-17 12:07:58 +01:00
syncToBigDiskName "monolith"
2023-02-17 11:40:28 +01:00