Recently, I had to move an app from one server to a new one. My preferred method of migration is always using the cPanel’s Transfer Tool which works absolutely great all the time.
However, this time around – this method didn’t work for me as the existing server did not have enough disk space.
As a workaround, I employed rsync which is a great utility to create an SSH tunnel between the servers and migrate the data. Just in case the script/execution dies for whatever reason, I used the –ignore-existing flag to be able to run the command again and let it pick up from where it left off.
Here is what the command looked like:
rsync -rav --ignore-existing -e 'ssh -p 22222' root@remote:/path/to/source/directory/ /path/to/destination/directory
- rsync is the tool
- -rav are options, r for recurrent, a for retaining attributes, and v for verbose output so you can see the files being copied.
- –ignore-existing would skip files that already exist, which helps speed up the process.
- -e ‘ssh -p 22222’ is used to open the SSH tunnel on a custom port
- root is the username on remote server
- @remote is the server we want to connect
- :/path/to/source/directory/ is the folder we want to copy over. Note – trailing slash here!
- /path/to/destination/directory is the folder we want to store the data. Note – no trailing slash here!
Once the data is migrated, I simply deleted it off the old server and went back to using cPanel Transfer Tool to complete the process.