rsync change le atime quand il lit /var/spool/mail
rorganisation mineure du script -- Sayan darcs-hash:20040424141234-d1356-54deadfa8d94b80b05c3a69828ac2977a16e10d6.gz
This commit is contained in:
parent
0841b5d90d
commit
7b50728bc1
1 changed files with 15 additions and 18 deletions
33
backup.sh
33
backup.sh
|
@ -6,29 +6,22 @@
|
|||
## Ajout de la synchro des mails : Sayan 19/10/2003
|
||||
## Ajout de la synchro des news et des homes : Sayan 15/11/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 ?
|
||||
# via tar bzip2
|
||||
confs="etc usr/cvs-rep CRANS usr/scripts boot/config*"
|
||||
# via rsync
|
||||
site_web="/home/httpd/CVS-Repository"
|
||||
confs="etc usr/cvs-rep CRANS usr/scripts boot/config*" # via bzip2
|
||||
site_web="/home/httpd/CVS-Repository" # via rsync
|
||||
mails="/var/spool/mail"
|
||||
news="/var/spool/news"
|
||||
homes="/home"
|
||||
|
||||
## Sauvegarde des confs: tar gz ($confs + dpkg_selections)
|
||||
cd /
|
||||
|
||||
# tgz le contenu des répertoires
|
||||
# ajoute dpkg --get-selections
|
||||
# echo Preparing to backup configs...
|
||||
temp_dir=$(mktemp -d)
|
||||
nom_archive=$temp_dir"/backup_"$(hostname)"_"$(date --iso-8601)".tar.bz2"
|
||||
nom_selections=$temp_dir"/selections"
|
||||
dpkg --get-selections > $nom_selections || exit 1
|
||||
tar -cjf $nom_archive $confs .$nom_selections || exit 2
|
||||
# echo Sending configs to pegase...
|
||||
scp $nom_archive backupcrans@pegase: || exit 3
|
||||
rm -rf $temp_dir
|
||||
|
||||
# rsync over ssh pour le site web, les homes, les mails et les news
|
||||
# archive, compress, sparse, hard links, CVS exclude, remote shell
|
||||
|
@ -38,10 +31,17 @@ scp $nom_archive backupcrans@pegase: || exit 3
|
|||
week=$(date +%W) # numéro de la semaine
|
||||
week_mod2=$(( $week % 2 ))
|
||||
|
||||
## Sauvegarde du Site web et des News
|
||||
rsync -atzSHe ssh --delete $site_web backupcrans@pegase:~/backup-$week_mod2/httpd || exit 4
|
||||
rsync -atzSHe ssh --delete $mails backupcrans@pegase:~/backup-$week_mod2/var/spool || exit 5
|
||||
rsync -atzSHe ssh --delete $news backupcrans@pegase:~/backup-$week_mod2/var/spool || exit 6
|
||||
|
||||
## Sauvegarde des mails
|
||||
# rsync change le atime quand il lit le fichier, on perd la date de dernière consultation des mails pour le ménage des comptes
|
||||
mount /var/spool/mail -o remount,noatime
|
||||
rsync -atzSHe ssh --delete $mails backupcrans@pegase:~/backup-$week_mod2/var/spool || exit 5
|
||||
mount /var/spool/mail -o remount,atime
|
||||
|
||||
## Sauvegarde des homes
|
||||
# Les homes sont donnés à backupcrans.backup
|
||||
# "Permission denied" errors occur because backupcrans is not root on pegase. Ignoring
|
||||
temp=$(mktemp)
|
||||
|
@ -52,8 +52,5 @@ if [ -s $temp_mail ]
|
|||
then
|
||||
cat $temp_mail | mail -s "rsync error" roots
|
||||
fi
|
||||
|
||||
# clean
|
||||
rm -rf $temp_dir
|
||||
rm $temp
|
||||
rm $temp_mail
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue