servers backup scripts
This commit is contained in:
parent
5d075db351
commit
1ffc1968d5
13
README.md
13
README.md
@ -1,8 +1,19 @@
|
||||
# scripts de https://www.cipherbliss.com
|
||||
|
||||
FR: des scripts et ressources en vrac évoqués sur mon blog
|
||||
EN: open code and ressources from my blog
|
||||
|
||||
EN: open code and ressources from my blog
|
||||
# Racine du dépot
|
||||
De quoi rafraîchir ce dépot avec des fichiers de configuration que j'utilise.
|
||||
|
||||
# Assets
|
||||
De quoi initialiser son utilisation d'orgmode
|
||||
|
||||
# Bash
|
||||
- sauvegardes avec borgbackup
|
||||
- script de post installation pour des distributions comme Debian, pour mettre les logiciels que j'utilise
|
||||
|
||||
# dossier partagé contenant des installateurs
|
||||
# license
|
||||
AGPLv3+
|
||||
|
||||
|
4
bash/backups/borg_peertube.sh
Normal file
4
bash/backups/borg_peertube.sh
Normal file
@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
|
||||
|
||||
borg create -C zlib,9 /home/tykayn/backup/borgbackup_peertube::peertube_prod_-{now:%Y-%m-%dT%H:%M:%S.%f} /var/www
|
@ -1,120 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
SOURCE="/media/tykayn/catwoman/backup_land4to"
|
||||
LOG_FILE_BACKUP=/media/tykayn/catwoman/stockage-syncable/www/backup/log_backup.log
|
||||
|
||||
# TODO optimize calls in a function
|
||||
|
||||
if [ -d "$SOURCE" ]; then
|
||||
|
||||
# rugged, portable usb3 4To
|
||||
echo " "
|
||||
echo " $(date) - copie vers le disque - rugged_tk"
|
||||
echo " "
|
||||
if [ -d "/media/tykayn/rugged_tk" ]; then
|
||||
echo " =================================================================";
|
||||
echo " =============== copie vers rugged ===============";
|
||||
echo " =================================================================";
|
||||
rsync -avzP --delete --delete-delay --info=progress2 $SOURCE /media/tykayn/rugged_tk | tee -a $LOG_FILE_BACKUP 2>&1
|
||||
echo " ========================== rugged ok ==========================";
|
||||
echo " ========================== $(date) rugged ok ==========================" >> $LOG_FILE_BACKUP;
|
||||
else
|
||||
echo " ========================== disque rugged non détecté ==========================";
|
||||
echo " ========================== $(date) disque rugged non détecté ==========================" >> $LOG_FILE_BACKUP;
|
||||
fi
|
||||
|
||||
|
||||
echo " "
|
||||
echo " copie vers le disque - 5DFE59D17034C63C"
|
||||
echo " "
|
||||
if [ -d "/media/tykayn/5DFE59D17034C63C" ]; then
|
||||
|
||||
echo " =================================================================";
|
||||
echo " =============== copie vers tk4to 5DFE59D17034C63C ===============";
|
||||
echo " =================================================================";
|
||||
# copie de borg local vers disque tk4to, 4To disque 3.5"
|
||||
rsync -avzP --delete --delete-delay --info=progress2 $SOURCE /media/tykayn/5DFE59D17034C63C | tee -a $LOG_FILE_BACKUP 2>&1
|
||||
|
||||
echo " ========================== tk4to 5DFE59D17034C63C ok ==========================";
|
||||
echo " ========================== $(date) disque rugged non détecté ==========================" >> $LOG_FILE_BACKUP;
|
||||
else
|
||||
echo " ========================== disque tk4to 5DFE59D17034C63C non détecté ==========================";
|
||||
fi
|
||||
|
||||
echo " "
|
||||
echo " copie vers le disque - blue_tk"
|
||||
echo " "
|
||||
if [ -d "/media/tykayn/blue_tk" ]; then
|
||||
echo " =================================================================";
|
||||
echo " =============== copie vers blue_tk ===============";
|
||||
echo " =================================================================";
|
||||
# blue, portable usb3 4To
|
||||
rsync -avzP --delete --delete-delay --info=progress2 $SOURCE /media/tykayn/blue_tk | tee -a $LOG_FILE_BACKUP 2>&1
|
||||
|
||||
|
||||
echo " ========================== blue_tk ok ==========================";
|
||||
echo " ========================== $(date) blue_tk ok ==========================" >> $LOG_FILE_BACKUP;
|
||||
else
|
||||
echo " ========================== disque blue_tk non détecté ==========================";
|
||||
fi
|
||||
|
||||
echo " "
|
||||
echo " copie vers le disque - louisbraille"
|
||||
echo " "
|
||||
if [ -d "/media/tykayn/louisbraille" ]; then
|
||||
echo " =================================================================";
|
||||
echo " =============== copie vers louisbraille ===============";
|
||||
echo " =================================================================";
|
||||
# blue, portable usb3 4To
|
||||
rsync -avzP --delete --delete-delay --info=progress2 $SOURCE /media/tykayn/louisbraille | tee -a $LOG_FILE_BACKUP 2>&1
|
||||
|
||||
|
||||
echo " ========================== louisbraille ok ==========================";
|
||||
echo " ========================== $(date) louisbraille ok ==========================" >> $LOG_FILE_BACKUP;
|
||||
else
|
||||
echo " ========================== disque louisbraille non détecté ==========================";
|
||||
fi
|
||||
echo " "
|
||||
echo " copie vers le disque - goliath 9To btrfs"
|
||||
echo " "
|
||||
if [ -d "/media/tykayn/goliath" ]; then
|
||||
echo " =================================================================";
|
||||
echo " =============== copie vers goliath ===============";
|
||||
echo " =================================================================";
|
||||
# blue, portable usb3 4To
|
||||
rsync -avzP --delete --delete-delay --info=progress2 $SOURCE /media/tykayn/goliath | tee -a $LOG_FILE_BACKUP 2>&1
|
||||
|
||||
|
||||
echo " ========================== goliath ok ==========================";
|
||||
echo " ========================== $(date) goliath ok ==========================" >> $LOG_FILE_BACKUP;
|
||||
else
|
||||
echo " ========================== disque goliath non détecté ==========================";
|
||||
fi
|
||||
echo " "
|
||||
echo " copie vers le disque - brossadent btrfs"
|
||||
echo " "
|
||||
if [ -d "/media/tykayn/goliath" ]; then
|
||||
echo " =================================================================";
|
||||
echo " =============== copie vers brossadent ===============";
|
||||
echo " =================================================================";
|
||||
# blue, portable usb3 4To
|
||||
rsync -avzP --delete --delete-delay --info=progress2 $SOURCE /media/tykayn/brossadent | tee -a $LOG_FILE_BACKUP 2>&1
|
||||
|
||||
|
||||
echo " ========================== brossadent ok ==========================";
|
||||
echo " ========================== $(date) brossadent ok ==========================" >> $LOG_FILE_BACKUP;
|
||||
else
|
||||
echo " ========================== disque brossadent non détecté ==========================";
|
||||
fi
|
||||
|
||||
|
||||
echo ""
|
||||
echo " ========================== fin de syncro de disques externes à Spaceship ==========================";
|
||||
echo " ========================== $(date) fin de syncro de disques externes à Spaceship ==========================" >> $LOG_FILE_BACKUP;
|
||||
else
|
||||
echo "!!!! dossier source non trouvé !!!!"
|
||||
echo " ========================== $(date) !!!! dossier source non trouvé !!!! ==========================" >> $LOG_FILE_BACKUP;
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
8
bash/backups/mount_local.sh
Normal file
8
bash/backups/mount_local.sh
Normal file
@ -0,0 +1,8 @@
|
||||
echo "############"
|
||||
echo "montage local du dossier borg FATland"
|
||||
echo "############"
|
||||
|
||||
borg mount /media/tykayn/DATA/backup_land4to /media/tykayn/DATA/temp_borgmount
|
||||
|
||||
echo -e "${GREEN}############${NC}"
|
||||
echo -e "${GREEN}syncro backup vers disque NAS BROUMIAH faite${NC}"
|
21
bash/backups/prod_backup_soy_spare_vps_cloud_to_DATA.sh
Normal file
21
bash/backups/prod_backup_soy_spare_vps_cloud_to_DATA.sh
Normal file
@ -0,0 +1,21 @@
|
||||
echo "############"
|
||||
echo " ${date} syncro du dossier borg de soyoustart vers le disque DATA local de FATland"
|
||||
echo "############"
|
||||
|
||||
|
||||
SOURCE="tykayn@cipherbliss.com:/home/tykayn/backup/borgbackup_soy/*"
|
||||
# sftp://tykayn@cipherbliss.com/home/tykayn/backup/borgbackup_soy
|
||||
DESTINATION="/media/tykayn/DATA/borgbackup_soy"
|
||||
|
||||
rsync -avzP --perms --delete --progress $SOURCE -e ssh $DESTINATION
|
||||
|
||||
echo -e "${GREEN}############${NC}"
|
||||
echo -e "${GREEN} ${date} syncro du dossier borg de soyoustart ok ${NC}"
|
||||
|
||||
# peertube
|
||||
SOURCE="tykayn@peertube.cipherbliss.com:/home/tykayn/backup/borgbackup_peertube/*"
|
||||
# sftp://tykayn@cipherbliss.com/home/tykayn/backup/borgbackup_soy
|
||||
DESTINATION="/media/tykayn/DATA/borgbackup_peertube"
|
||||
|
||||
rsync -avzP --perms --delete --progress $SOURCE -e ssh $DESTINATION
|
||||
|
11
bash/backups/s_peertube_from_spaceship.sh
Normal file
11
bash/backups/s_peertube_from_spaceship.sh
Normal file
@ -0,0 +1,11 @@
|
||||
echo "############"
|
||||
echo " ${date} syncro du dossier BORG local de fatland vers SPARE peertube.cipherbliss.com"
|
||||
echo "############"
|
||||
|
||||
SOURCE="/media/tykayn/catwoman/backup_land4to/*"
|
||||
DESTINATION="tykayn@peertube.cipherbliss.com"
|
||||
DESTINATION_FOLDER="/home/tykayn/backup/backup_land4to"
|
||||
rsync -avzP --perms --delete --progress $SOURCE -e ssh $DESTINATION:$DESTINATION_FOLDER
|
||||
|
||||
echo -e "${GREEN}############${NC}"
|
||||
echo -e "${GREEN} ${date}syncro backup vers disque vers soyoustart cipherbliss.com ${NC}"
|
36
bash/backups/soyoustart_borg.sh
Normal file
36
bash/backups/soyoustart_borg.sh
Normal file
@ -0,0 +1,36 @@
|
||||
#!/bin/bash
|
||||
# ------------- pour créer le dépot borg:
|
||||
# borg init --encryption=repokey-blake2 /media/tykayn/catwoman/stockage-syncable
|
||||
# ------------- ajouter dans la crontab root
|
||||
# sudo crontab -e
|
||||
# # lancer toutes les 4 heures le script de création borg
|
||||
# 0 */4 * * * bash /home/tykayn/soyoustart_borg.sh
|
||||
#
|
||||
# -------------
|
||||
# config
|
||||
#
|
||||
today=$(date +"%Y-%m-%d_%H-%I-%S")
|
||||
LOG_FILE_BACKUP=/home/tykayn/backup/log_backup_soyoustart.log
|
||||
BORG_FOLDER_SOYOUSTART=/home/tykayn/backup/borgbackup_soy
|
||||
export BORG_PASSCOMMAND="cat /home/tykayn/.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
|
||||
AUTOMYSQL_FOLDER=/home/tykayn/backup/automysqlbackup
|
||||
AUTOPOSTGRE_FOLDER=/home/tykayn/backup/autopostgresqlbackup
|
||||
WEBSITES_FOLDER=/home/www
|
||||
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} | SOYOUSTART | start backup script soyoustart_borg.sh " | tee -a $LOG_FILE_BACKUP 2>&1
|
||||
|
||||
borg create $BORG_FOLDER_SOYOUSTART::soyoustart_{user}-{now} $AUTOMYSQL_FOLDER $AUTOPOSTGRE_FOLDER $WEBSITES_FOLDER $NGINX_FOLDER --exclude '.bundler/gems' --exclude 'node_modules' --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
|
||||
|
||||
echo "### ${date} | SOYOUSTART | done borg_spaceship.sh " | tee -a $LOG_FILE_BACKUP 2>&1
|
29
bash/backups/sync_soy_to_cloud.sh
Normal file
29
bash/backups/sync_soy_to_cloud.sh
Normal file
@ -0,0 +1,29 @@
|
||||
#!/bin/bash
|
||||
# rsync_other_servers_from_soyoustart.sh
|
||||
# --------------------- syncro des différents serveurs ---------------------
|
||||
# ici on clone le dossier borg vers les autres serveurs BORG_FOLDER_SOYOUSTART
|
||||
# tous les autres serveurs ont un dossier /home/tykayn/backup/serveurs-production contenant le nom de$
|
||||
#
|
||||
# /home/tykayn/backup/serveurs-production/soyoustart
|
||||
# /home/tykayn/backup/serveurs-production/peertube
|
||||
# /home/tykayn/backup/serveurs-production/vps
|
||||
# /home/tykayn/backup/serveurs-production/cloud
|
||||
#
|
||||
# ------- noms des serveurs --------
|
||||
#
|
||||
# CLOUD cloud.tykayn.fr
|
||||
# SPARE peertube.cipherbliss.com
|
||||
# VPS events.cipherbliss.com
|
||||
# SOY www.cipherbliss.com
|
||||
|
||||
|
||||
echo "############"
|
||||
echo " ${date} syncro du dossier BORG backup de tk sur soyoustart vers Cloud"
|
||||
echo "############"
|
||||
|
||||
SOURCE="/home/tykayn/backup/backup_land4to/*"
|
||||
DESTINATION="tykayn@peertube.cipherbliss.com:/home/tykayn/backup/backup_land4to/"
|
||||
rsync -avzP --perms --delete --progress $SOURCE -e ssh $DESTINATION
|
||||
|
||||
echo -e "${GREEN}############${NC}"
|
||||
echo -e "${GREEN} ${date}syncro backup vers disque vers soyoustart cipherbliss.com ${NC}"
|
9
bash/backups/sync_to_nas.sh
Normal file
9
bash/backups/sync_to_nas.sh
Normal file
@ -0,0 +1,9 @@
|
||||
echo "############"
|
||||
echo "syncro du dossier BORG local de fatland vers le NAS BROUMIAH"
|
||||
echo "############"
|
||||
|
||||
SOURCE="/media/tykayn/DATA/backup_land4to/*"
|
||||
rsync -avzP --perms --delete-after --progress $SOURCE -e ssh tykayn@192.168.0.3/var/services/homes/tykayn/archives/backup_land4to -p 20522
|
||||
|
||||
echo -e "${GREEN}############${NC}"
|
||||
echo -e "${GREEN}syncro backup vers disque NAS BROUMIAH faite${NC}"
|
11
bash/backups/sync_to_peertube.sh
Normal file
11
bash/backups/sync_to_peertube.sh
Normal file
@ -0,0 +1,11 @@
|
||||
echo "############"
|
||||
echo " ${date} syncro du dossier BORG local de fatland vers SPARE peertube.cipherbliss.com"
|
||||
echo "############"
|
||||
|
||||
SOURCE="/media/tykayn/DATA/backup_land4to/*"
|
||||
DESTINATION="tykayn@peertube.cipherbliss.com"
|
||||
DESTINATION_FOLDER="/home/tykayn/backup/backup_land4to"
|
||||
rsync -avzP --perms --delete --progress $SOURCE -e ssh $DESTINATION:$DESTINATION_FOLDER
|
||||
|
||||
echo -e "${GREEN}############${NC}"
|
||||
echo -e "${GREEN} ${date}syncro backup vers disque vers soyoustart cipherbliss.com ${NC}"
|
16
bash/git/.gitconfig
Normal file
16
bash/git/.gitconfig
Normal file
@ -0,0 +1,16 @@
|
||||
[credential]
|
||||
helper = store
|
||||
[user]
|
||||
email = contact@cipherbliss.com
|
||||
name = tykayn
|
||||
[filesystem "Ubuntu|11.0.7|/dev/mapper/kubuntu--vg-root"]
|
||||
timestampResolution = 5000 nanoseconds
|
||||
minRacyThreshold = 7537 microseconds
|
||||
[rerere]
|
||||
enabled = true
|
||||
[diff]
|
||||
submodule = log
|
||||
[core]
|
||||
editor = gedit
|
||||
[init]
|
||||
defaultBranch = main
|
@ -22,6 +22,10 @@ cp "$HOME_OF_USERNAME_CURRENT/Nextcloud/textes/orgmode/style.css" "$HOME_OF_SCRI
|
||||
cp "$HOME_OF_USERNAME_CURRENT/Nextcloud/textes/orgmode/upcalendar.sh" "$HOME_OF_SCRIPTS/assets/org" -r
|
||||
|
||||
# sauvegardes
|
||||
cp "$HOME_OF_USERNAME_CURRENT/sync_spaceship.sh" "$HOME_OF_SCRIPTS/bash/backups"
|
||||
cp "$HOME_OF_USERNAME_CURRENT/test-func.sh" "$HOME_OF_SCRIPTS/bash/backups"
|
||||
cp "$HOME_OF_USERNAME_CURRENT/functions_sync.sh" "$HOME_OF_SCRIPTS/bash/backups"
|
||||
|
||||
|
||||
echo "HOME_OF_SCRIPTS : $HOME_OF_SCRIPTS"
|
||||
ls -l "$HOME_OF_SCRIPTS/assets/org"
|
||||
|
Loading…
Reference in New Issue
Block a user