Wednesday, October 6, 2021

thumbnail

Using rsync to migrate data from one storage to another storage

Migrating data from one server to another server || Migrating data from old storage to new storage



To migrate or copy the data from one server to another server we can use rsync or scp tool. for better results i would suggest to use rsync so that we can preserve the same kind of permission, symlink and everything when it copied over to the new location.

In this example, am migrating data from older VNX storage to new Unity 680F storage. so first i had created the new file system on the new storage with required size to accommodate old storage data and also enabled SMB storage to access the same share from windows side

To find out how to create file system on the Unity storage refer another link.

I have created new file system on the Unity storage and then mounted that new file system and older one in the acg-vm1 centos 7 server and from there i will be running rsync to copy the data to new file system with preserving file permissions.

1. Use the following rsync command to migrate the data. .ckpt is for the snapshot to be excluded, & sign at the end to run the job in the background and 2>&1 for sending the standard error and output to the log file

# vi home-data-sync.sh
#!/bin/bash

/usr/bin/rsync -v -v -a -P -x -H -p -E --exclude '.ckpt*' --delete-excluded --ignore-errors --delete /mnt/oldhome/* /mnt/new-home1/ > /root/oldhome/oldhome.log 2>&1 &

2. Once data copied or rsync job completed you can verify the logs if there is any error reported or you can also run echo $? to see if the error code 0 means no error


# echo $?
0

3. You can then verify the size on both old and new location if it matches to make sure all data copied

4. You can use the following command to find the usage. if you do not want to sort the size then you can remove sort -rh option. This will get the all the folders usage size under /mnt/oldhome/ directory

# cd /mnt/oldhome/
# du -h --max-depth=1 *   --exclude=terminated   | sort -rh > /root/oldhomedir_usage-10062021.txt


Subscribe by Email

Follow Updates Articles from This Blog via Email

No Comments

Powered by Blogger.