46 lines
1.5 KiB
Bash
Executable file
46 lines
1.5 KiB
Bash
Executable file
#!/bin/sh
|
|
|
|
## Sauvegarde des fichiers de conf et du site web CRANS sur Tanek
|
|
## Sayan 02/10/2003
|
|
## Ajout de la synchro du site web : Sayan 04/10/2003
|
|
## Ajout de la synchro des mails : Sayan 19/10/2003
|
|
|
|
## Nom de fichiers et chemins
|
|
temp_dir=$(mktemp -d)
|
|
nom_archive=$temp_dir"/backup_"$(hostname)"_"$(date --iso-8601)".tar.bz2"
|
|
nom_selections=$temp_dir"/selections"
|
|
|
|
## Que sauvegarder ?
|
|
confs="etc usr/cvs-rep CRANS usr/scripts boot/config*" # via tar bzip2
|
|
site_web="home/httpd/CVS-Repository" # via rsync
|
|
mails="var/spool/mail"
|
|
|
|
cd /
|
|
|
|
# tgz le contenu des répertoires
|
|
# ajoute dpkg --get-selections
|
|
dpkg --get-selections > $nom_selections || exit 1
|
|
tar -cjf $nom_archive $confs .$nom_selections || exit 2
|
|
|
|
# scp le fichier sur tanek
|
|
scp $nom_archive backupcrans@tanek: || exit 3
|
|
|
|
# rsync over ssh pour le site web
|
|
# archive, compress, sparse, hard links, CVS exclude, remote shell
|
|
# suppr les fichiers non existant sur zamok
|
|
# synchro journalière, switch par semaine
|
|
week=$(date +%W) # numéro de la semaine
|
|
week_mod2=$(( $week % 2 ))
|
|
rsync -azSHCe ssh --delete $site_web backupcrans@tanek:~/httpd-$week_mod2 || exit 4
|
|
|
|
# rsync over ssh pour les mails
|
|
# archive, compress, sparse, hard links, CVS exclude, remote shell
|
|
# suppr les fichiers non existant sur zamok
|
|
# synchro journalière, switch par semaine
|
|
week=$(date +%W) # numéro de la semaine
|
|
week_mod2=$(( $week % 2 ))
|
|
rsync -azSHCe ssh --delete $mails backupcrans@tanek:/mnt/backup$week_mod2/var/spool || exit 5
|
|
|
|
|
|
# clean
|
|
rm -rf $temp_dir
|