====== Using Rsync ======
===== syncing, backuping =====
rsync makes //easy// to make incremental backups : it synchronise files from two different folders and only transferts what have changed.
===== rsync over ssh =====
In daily work, it is good to have 2 versions of my work synchronised :
* one is on my local machine as work version
* one is on a distant server as test version
Those versions have to be synchronised
rsync_all.sh
rsync -a -c -z -l -e ssh --delete --stats --progress --exclude-from 'rsync_exclude.txt' "spip/" "freelancis@freelancis.net:./mcs.freelancis.net/web/"
rsync_exclude.txt
svn.*
.git
.gitignore
tmp/prive_spip.*
tmp/spip.*
tmp/cache/*
tmp/sessions/*
tmp/visites/*
local/*
.DS_Store
*/.DS_Store
===== rsync for backup =====
{{:ressources:ssh:ubuntu_timemachine.jpg|}}
let's make my backups
* using TimeMachine is a good option under Mac OS 10.5 : it keeps tracks of each version, see at the [[:ressources:ubuntu:bonjour|bonjour tutorial]] for setting it up with an ubuntu server
* some alternative could be to use rsync
===== rsync to get interrupted ssh connection =====
When my scp connexion is interrupted, rsync --partial makes the trick
nyx:~ gaspard$ scp -C idunn.freelancis.net:./wp_db.gz .
gaspard@idunn.freelancis.net s password:
wp_db.gz 49% 738MB 0.0KB/s - stalled -Read from remote host
idunn.freelancis.net: Connection reset by peer
lost connection
nyx:~ gaspard$ rsync --partial idunn.freelancis.net:./wp_db.gz .
gaspard@idunn.freelancis.net s password:
===== rsync to backup my server =====
Where are important data on my server ?
^path ^ user ^ description ^
|/etc/apache2/ |root | apache configuration |
|/home/freelancis/ |freelancis | hosted websites |
|/home/mysql/ |mysql |mysql databases |
I want the exact copy of these elements.
==== backuping /etc/apache2/ ====
I gonna have to use root shell, I hate to do this but it looks like it is the only way.
==== backuping /home/freelancis/ ====
rsync -a -c -z -e ssh --delete --stats --progress --exclude-from 'rsync_exclude_user_freelancis.txt' "freelancis@freelancis.net:." "user_freelancis"
I just don't need the cached elements, that's why I discard them by using a rsync_exclude_user_freelancis.txt file
tmp/cache/
data/cache/
==== /home/mysql/ ====
There is no shell user as mysql, so i gonna have to use root.
===== rsync command lines =====
* -v, --verbose increase verbosity
* -q, --quiet decrease verbosity
* -c, --checksum always checksum
* -a, --archive archive mode. It is a quick way of saying you want recursion and want to preserve everything.
* -r, --recursive recurse into directories
* -R, --relative use relative path names
* -u, --update don't overwrite files that are newer on the destination directory
* -t, --times preserve times
* -n, --dry-run show what would have been transferred
* -W, --whole-file copy whole files, no incremental checks
* -I, --ignore-times Normally rsync will skip any files that are already the same length and have the same time-stamp. This option turns off this behavior.
* --existing only update files that already exist
* --delete delete files that don't exist on the sending side
* --delete-after delete after transferring, not before
* --force force deletion of directories even if not empty
* -c, --checksum always checksum
* --size-only only use file size when determining if a file should be transferred
* --progress show progress during transfer
* -z, --compress compress file data
* --exclude=PATTERN exclude files matching PATTERN
* --daemon run as a rsync daemon
* --password-file=FILE get password from FILE
===== more ressources =====
* [[http://rootprompt.org/article.php3?article=8976|Noel Davis' backup script]] is a good start, do I need the same parameters ? do these arguments are still valid on latest build of rsync ?
* [[Mike's tutorial|http://www.mikerubel.org/computers/rsync_snapshots/]] is quite good too, goot things to gather there