Using rsync to backup files from one server to other
Rsync is command mostly used in linux to backup files to backup server or if you want files to be copies to another server.
Create a key using
copy the key from main server to backup server.
ssh-copy-id -i ~/.ssh/id_rsa.pub -p 400 [email protected]
once its copies try login into back machine.
ssh -p '400' '[email protected]'
now you can login without entering the password, if all working then you can test rsync commandtry this command to copy files from main server to test server.
rsync -arvz -e "ssh -p 400 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" --progress /var/www/html/myfiles/* [email protected]:/home/username/backup/*
In the above setup we are doing rsync using some options and custom port 400 to the backup folder in home directory in backup server.
to run this rsync add it to crontab to run the time whenever you want..