Saturday, September 24, 2016

Ubuntu / rsync backup


 https://www.digitalocean.com/community/tutorials/how-to-upgrade-ubuntu-12-04-lts-to-ubuntu-14-04-lts

 The aAX flags tell rsync to preserve important file attributes like permissions, ownerships, and modification times. If you are using Docker or another virtualization tool, you should add the S flag so that rsync properly handles sparse files, like virtual storage.

sudo rsync -aAXv --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} -e 'ssh -i /path/to/private_key' root@SERVER_IP_ADDRESS:/* ~/backup/
 
sudo rsync -aAXv --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*", \
"/mnt/*","/media/*","/lost+found"} -e 'ssh -i /path/to/private_key' \
root@SERVER_IP_ADDRESS:/* ~/backup/ 

If you need to restore parts of your server files later on, you can use rsync 
again with the source and destination parameters reversed, like so:  
 
sudo rsync -aAXv -e 'ssh -i /path/to/private_key' ~/backup/ root@SERVER_IP_ADDRESS:/*

xx
 
How to deal with "/path/to/private_key" 

http://www.cyberciti.biz/faq/force-ssh-client-to-use-given-private-key-identity-file/

example:

ssh -i /path/to/id_rsa user@server.nixcraft.com
ssh -i /path/to/id_dsa user@server2.nixcraft.net.in

To use /backup/home/user/.ssh/id_dsa, enter:

ssh -i /backup/home/user/.ssh/id_dsa user@unixserver1.nixcraft.com


xx 

No comments:

Post a Comment