RSync :
Les éléments présent dans serveur sont synchronisé sur websebp (qui centralise)
Configuration SSH
Sur les 2 noeuds (sous root) :
mkdir ~/.ssh chmod 700 ~/.sshClé RSA :
/usr/bin/ssh-keygen -t rsa
à Pas de passphrase
Clé DSA :
/usr/bin/ssh-keygen -t dsa
à Pas de passphrase
Création du fichier d’authorisation :
$ touch ~/.ssh/authorized_keys
Sur websebp (root) :cd .ssh ssh websebp cat /root/.ssh/id_rsa.pub >> authorized_keys ssh websebp cat /root/.ssh/id_dsa.pub >> authorized_keys ssh serveur cat /root/.ssh/id_rsa.pub >> authorized_keys ssh serveur cat /root/.ssh/id_dsa.pub >> authorized_keys scp authorized_keys serveur:/root/.ssh/ chmod 600 ~/.ssh/authorized_keys
Sur serveur (root):$cd .ssh ssh serveur cat /root/.ssh/id_rsa.pub >> authorized_keys ssh serveur cat /root/.ssh/id_dsa.pub >> authorized_keys
Sur websebp (root)scp serveur:/root/.ssh/authorized_keys .
Synchronisation /var/www sur “serveur vers /home/bdemolon/serveur
Sur websebp (root)
rsync -e ssh -varuzP serveur:/var/www /home/bdemolon/serveur
root@websebp:~# scp .ssh/id_dsa.pub serveur:/root/.ssh
root@websebp:~# cat rsync2.sh
J=`date +%d` M=`date +%b` Y=`date +%y` H=`date +%H` m=`date +%M` DATEDUJOUR=$J$M$Y.$H:$m rsync -arvtgo –stats –delete –backup –backup-dir=/home/bdemolon/serveur-incr/MENSUEL/INCREMENTAL/$DATEDUJOUR -e ssh serveur:/var/lib/mysql /home/bdemolon/serveur-incr/MENSUEL/PRINCIPALE
root@websebp:~# cat rsync.sh
rsync -e ssh -varuzP serveur:/var/www /home/bdemolon/serveur rsync -e ssh -varuzP serveur:/var/lib/mysql /home/bdemolon/serveur
root@serveur:/home/bdemolon# cat backup.sh
rsync -arvtgo –stats –delete –backup –backup-dir=/home/bdemolon/MENSUEL/incrementale/$DATEDUJOUR -e ssh root@localhost:/var /home/bdemolon/MENSUEL/principal
rsync -arvtgo –stats –delete –backup –backup-dir=/home/bdemolon/MENSUEL/incrementale/$DATEDUJOUR -e ssh root@localhost:/etc /home/bdemolon/MENSUEL/principal
rsync -arvtgo –stats –delete –backup –backup-dir=/home/bdemolon/MENSUEL/incrementale/$DATEDUJOUR -e ssh root@localhost:/opt /home/bdemolon/MENSUEL/principal
crontab –e
0 23 * * * /home/bdemolon/backup.sh
A voir…
http://www.commentcamarche.net/forum/affich-2866167-rsync-backup-incremental-sur-un-mois http://www.linuxfocus.org/Francais/March2004/article326.shtml http://www.howtoforge.com/rsync_incremental_snapshot_backups
backup.sh
#!/bin/bash unset PATH # USER VARIABLES BACKUPDIR=/backup # Folder on the backup server where the backups shall be located KEY=/root/.ssh/id_rsa # SSH key MYSQL_BACKUPSCRIPT=/root/my_backup.sh # Path to the remote mysql backup script PRODUCTION_USER=root@production.server.com # The user and the address of the production server EXCLUDES=/backup/backup_exclude # File containing the excluded directories DAYS=60 # The number of days after which old backups will be deleted # PATH VARIABLES SH=/bin/sh # Location of the bash bin in the production server!!!! CP=/bin/cp; # Location of the cp bin FIND=/usr/bin/find; # Location of the find bin ECHO=/bin/echo; # Location of the echo bin MK=/bin/mkdir; # Location of the mk bin SSH=/usr/bin/ssh; # Location of the ssh bin DATE=/bin/date; # Location of the date bin RM=/bin/rm; # Location of the rm bin GREP=/bin/grep; # Location of the grep bin MYSQL=/usr/bin/mysql; # Location of the mysql bin MYSQLDUMP=/usr/bin/mysqldump; # Location of the mysql_dump bin RSYNC=/usr/bin/rsync; # Location of the rsync bin TOUCH=/bin/touch; # Location of the touch bin ## ## ## – DO NOT EDIT BELOW THIS HERE – ## ## ## # CREATING NECESSARY FOLDERS $MK $BACKUPDIR CURRENT=$BACKUPDIR/current OLD=$BACKUPDIR/old $MK $CURRENT $MK $OLD # CREATING CURRENT DATE / TIME NOW=`$DATE ‘+%Y-%m’-%d_%H:%M` NOW=$OLD/$NOW $MK $NOW # CREATE REMOTE MYSQL BACKUP BY RUNNING THE REMOTE BACKUP SCRIPT $SSH -i $KEY $PRODUCTION_USER « $SH $MYSQL_BACKUPSCRIPT » # RUN RSYNC INTO CURRENT $RSYNC \ -apvz –delete –delete-excluded –exclude-from= »$EXCLUDES » -e « $SSH -i $KEY » \ $PRODUCTION_USER:/ \ $CURRENT ; # UPDATE THE MTIME TO REFELCT THE SNAPSHOT TIME $TOUCH $BACKUPDIR/current # MAKE HARDLINK COPY $CP -al $CURRENT/* $NOW # REMOVE OLD BACKUPS for FILE in « $( $FIND $OLD -maxdepth 1 -type d -mtime +$DAYS ) » do # $RM -Rf $FILE # $ECHO $FILE done exit 0
RDIFFWEB
RDIFF-BACKUP-WEB
Blog of the year award…
That discussion was so great. I bestow upon you the Best Blogger Award 2011….