[Linux-bruxelles] Clonage de serveur

eric hanuise ehanuise at fantasybel.net
Mar 4 Oct 13:55:37 CEST 2005


perso j'utilise ce petit script maison poru els backups.
Quand je dois recopier un serveur, je fais une install sur le nouveau 
sereur et je restore ca dessus. Moyennant queklques adaptations, ca ce 
passe généralement assez bien.

(/home/backups/ correspond souvent sur mes macines a un share sur un 
serveur externe ou a un second disque dur dédié a cet usage)

backitup.sh

#!/bin/bash
# gnu tar syntax used here : tar -czv --atime-preserve --absolute-names 
-f [filename] [target] > [logfile]
# -c : create (replaces existing one if any)
# -z : compress using gnuzip
# -v : be verbose
# --atime-preserve : don't mess modtimes
# --absolute-names : keep root tree hierarchy
# --exclude [name] : exclude file or folder named [name]
# -f [filename] archive name
# [target] : file/folders to backup
# > [logfile] : send output to a logfile
tar -czv --atime-preserve --absolute-names --exclude backups -f 
/home/backups/home.tgz /home >/home/backups/home.log
tar -czv --atime-preserve --absolute-names -f /home/backups/initrd.tgz 
/initrd >/home/backups/initrd.log
tar -czv --atime-preserve --absolute-names -f /home/backups/bin.tgz /bin 
 >/home/backups/bin.log
tar -czv --atime-preserve --absolute-names -f /home/backups/boot.tgz 
/boot >/home/backups/boot.log
tar -czv --atime-preserve --absolute-names -f /home/backups/etc.tgz /etc 
 >/home/backups/etc.log
tar -czv --atime-preserve --absolute-names -f /home/backups/lib.tgz /lib 
 >/home/backups/lib.log
tar -czv --atime-preserve --absolute-names -f /home/backups/opt.tgz /opt 
 >/home/backups/opt.log
tar -czv --atime-preserve --absolute-names -f /home/backups/sbin.tgz 
/sbin >/home/backups/sbin.log
tar -czv --atime-preserve --absolute-names --exclude local -f 
/home/backups/usr.tgz /usr >/home/backups/usr.log
tar -czv --atime-preserve --absolute-names -f /home/backups/usrlocal.tgz 
/usr/local >/home/backups/usrlocal.log
tar -czv --atime-preserve --absolute-names -f /home/backups/var.tgz /var 
 >/home/backups/var.log
tar -czv --atime-preserve --absolute-names -f /home/backups/root.tgz 
/root >/home/backups/root.log

# now back up mysql databases
# mysqldump syntax : -a all , -l lock tables , -u username -p password
#mysqldump -a -l -uusername -ppassword database1 
 >/home/backups/database1-dump.sql
#mysqldump -a -l -uusername -ppassword database2 
 >/home/backups/database2-dump.sql
#etc...

# now backup all postgresql databases
# pg_dumpall syntax -o dupe OID's -U username
#/usr/lib/postgresql/bin/pg_dumpall -o -U username > 
#/home/backups/postgresql-dumpall.sql

touch /home/backups/completed
date > /home/backups/completed


-- 
----------------------------------------------------------------------
                    If it works, don't fix it.
----------------------------------------------------------------------
  ()  ascii ribbon campaign - against html mail
  /\                        - against microsoft attachments
----------------------------------------------------------------------
Why HTML in E-Mail is a Bad Idea
http://www.birdhouse.org/etc/evilmail.html
----------------------------------------------------------------------




Plus d'informations sur la liste de diffusion Linux-bruxelles