Skip to content

rsync all your home and mysql db to new server.

Some time you may want to backup your home directory and mysql databases to a new server, we can do that using rsync script. The below script when run from your new server will, rsync all your home dir to your new server.

#!/bin/bash
#by-admin@serversignature.com
#Old Server IP
IP=192.168.0.1
#Scrit is run from the new server to move the home and mysql data.
rsync -vrplogDtH --exclude=virtfs/ --progress -e ssh root@$IP:/home/ /home/
rsync -vrplogDtH --progress -e ssh root@$IP:/var/lib/mysql/ /var/lib/mysql/
#To backup individual mysql database.
cd /var/lib/mysql
rsync -vrplogDtH --progress -e ssh root@$IP:/var/lib/mysql/user_database .

Post a Comment

You must be logged in to post a comment.