Diferencia entre revisiones de «Rsync»
De gacq wiki
(→Backup using ssh) |
|||
Línea 1: | Línea 1: | ||
=Most used options= | =Most used options= | ||
− | -a, --archive archive mode | + | ==-a, --archive== |
+ | -a, --archive archive mode | ||
+ | '''same as -rlptgoD (no -H)''' | ||
-r, --recursive recurse into directories | -r, --recursive recurse into directories | ||
-l, --links copy symlinks as symlinks | -l, --links copy symlinks as symlinks | ||
Línea 8: | Línea 10: | ||
-o, --owner preserve owner (super-user only) | -o, --owner preserve owner (super-user only) | ||
-D same as --devices --specials | -D same as --devices --specials | ||
− | + | ||
+ | ==commons== | ||
-v, --verbose increase verbosity | -v, --verbose increase verbosity | ||
-u, --update skip files that are newer on the receiver | -u, --update skip files that are newer on the receiver | ||
Línea 15: | Línea 18: | ||
-h, --human-readable output numbers in a human-readable format | -h, --human-readable output numbers in a human-readable format | ||
--progress show progress during transfer | --progress show progress during transfer | ||
+ | -f, --filter=RULE add a file-filtering RULE | ||
+ | |||
+ | ==incremental== | ||
+ | -b, --backup destination files are renamed | ||
+ | --backup-dir=DIR for incremental backups | ||
+ | |||
+ | ==limits== | ||
--max-size=SIZE | --max-size=SIZE | ||
--bwlimit=KBPS limit I/O bandwidth; KBytes per second | --bwlimit=KBPS limit I/O bandwidth; KBytes per second | ||
− | + | ||
=My notebook syncronization= | =My notebook syncronization= |
Revisión del 20:36 3 oct 2006
Contenido
Most used options
-a, --archive
-a, --archive archive mode same as -rlptgoD (no -H) -r, --recursive recurse into directories -l, --links copy symlinks as symlinks -p, --perms preserve permissions -t, --times preserve times -g, --group preserve group -o, --owner preserve owner (super-user only) -D same as --devices --specials
commons
-v, --verbose increase verbosity -u, --update skip files that are newer on the receiver -z, --compress compress file data during the transfer -e, --rsh=COMMAND specify the remote shell to use -h, --human-readable output numbers in a human-readable format --progress show progress during transfer -f, --filter=RULE add a file-filtering RULE
incremental
-b, --backup destination files are renamed --backup-dir=DIR for incremental backups
limits
--max-size=SIZE --bwlimit=KBPS limit I/O bandwidth; KBytes per second
My notebook syncronization
gacq.com-get
echo Receiving..... rsync -avuze 'ssh -p 22' --delete anysyncuser@myserver:/srv/gacq/rsync/ rsync
gacq.com-put
echo Sending..... rsync -avuze 'ssh -p 22' --delete rsync anysyncuser@myserver:/srv/gacq/
Duplicando una maquina con rsync
rsync -v -r -p -o -g -D -t -S -l -H \ --exclude /mnt/ \ --exclude /proc/ \ --exclude /tmp/ \ --exclude /home/ / /mnt/fireball/
Boot from a CD-ROM and mount the target-disk. Fix fstab and lilo.conf. Create /mnt and /proc and set the right permissions (for this directories). Then run lilo and reboot. Next time you run rsync, add these option to the command-line:
--exclude /etc/fstab \ --exclude /etc/lilo.conf \ --delete
Backup using ssh
Commands to execute
At host to backup (as root)
useradd -g 0 -G daemon,dip,lpadmin,shadow,sasl rbackup passwd rbackup su - rbackup mkdir -p /home/rbackup/.ssh chmod 700 /home/rbackup/.ssh chown -R rbackup.root /home/rbackup
At backup server (as root)
ssh-keygen -t dsa -f rhost-id_dsa scp rhost-id_dsa.pub rbackup@rhost:.ssh/authorized_keys # test ssh -i rhost-id_dsa.pub rbackup@rhost
script (ssh)
#!/bin/sh # HOST=SERVER USER=REMOTE_USER MYSQLPASS=MYSQL_ROOT_PASS dir=full_backup date=`date +%F_%T | tr \: _` incremental=incremental/incremental_$date dumps=dumps/dump_$date mkdir -p $dir mkdir -p $incremental mkdir -p $dumps rsync -auzvh \ -e "ssh -l $USER -i $HOST-id_dsa" \ --delete \ --max-size=50M \ --filter='+ /etc/' \ --filter='+ /etc/**' \ --filter='+ /root/' \ --filter='+ /root/**' \ --filter='+ /usr/' \ --filter='+ /usr/local/' \ --filter='+ /usr/local/scripts/' \ --filter='+ /usr/local/scripts/**' \ --filter='- /**' \ --backup --backup-dir=../$incremental \ $HOST:/ $dir ssh -l $USER -i $HOST-id_dsa $HOST "/usr/bin/dpkg --get-selections" > $dumps/dpkg--get-selections.txt ssh -l $USER -i $HOST-id_dsa $HOST "mysqldump --all-databases --password=$MYSQLPASS | gzip" > $dumps/all-databases.sql.gz
Backup using rsyncd
/etc/rsyncd.conf
[all] comment = from root path = / read only = yes list = yes uid = root gid = root strict modes = yes hosts allow = gacq.com ignore errors = no ignore nonreadable = yes transfer logging = no timeout = 600 refuse options = checksum dry-run dont compress = *.gz *.tgz *.zip *.z *.rpm *.deb *.iso *.bz2 *.tbz
script (rsyncd)
#!/bin/sh # HOST=SERVER USER=REMOTE_USER MYSQLPASS=MYSQL_ROOT_PASS dir=full_backup date=`date +%F_%T | tr \: _` incremental=incremental/incremental_$date dumps=dumps/dump_$date mkdir -p $dir mkdir -p $incremental mkdir -p $dumps rsync -azvh \ --delete \ --max-size=50M \ --bwlimit=200 \ --progress \ --filter='+ /etc/' \ --filter='+ /etc/**' \ --filter='+ /root/' \ --filter='+ /root/**' \ --filter='+ /home/' \ --filter='+ /home/**' \ --filter='+ /usr/' \ --filter='+ /usr/local/' \ --filter='+ /usr/local/scripts/' \ --filter='+ /usr/local/scripts/**' \ --filter='- /**' \ --backup --backup-dir=../$incremental \ $HOST::all $dir ssh -l $USER -i $HOST-id_dsa $HOST "/usr/bin/dpkg --get-selections" > $dumps/dpkg--get-selections.txt ssh -l $USER -i $HOST-id_dsa $HOST "mysqldump --all-databases --password=$MYSQLPASS | gzip" > $dumps/all-databases.sql.gz
Using ssh
Change:
$HOST::all $dir
To:
$HOST:/all $dir