Say you're about to cancel a VPS, but first you need to copy its contents (source) over to another server (destination).
We will be using rsync
. Note: rsync will keep the original timestamps for both files and folders, so that's good.
General idea:
rsync --params source destination
Because we will copy the whole source VPS, we will have to do it using the root
account to avoid permission errors. Since most likely you won't be able to SSH into your source with root from any other server, instead you will have to su
to root on the source, and then SSH into the destination. Could be any account on the destination, but lets say it's admin
.
Updated general idea:
rsync --params / admin@example.com:/folder
Start by configuring SSH access from the source server to the destination server.
- Elevate to
root
on the source server:su -
orsudo su -
- Display and copy the public key of the root account:
cat ~/.ssh/id_rsa.pub
- Go to the destination server. Log in to the
admin
account. Open it's~/.ssh/authorized_keys
for editing and put the copied key in there. - Test the connection on the source server:
ssh admin@example.com -p 2222
Copying from this server to another
rsync -aAXvh --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found","/usr/*","/lib/*","/opt/*","/var/cache/*","/var/lib/*"} -e 'ssh -p 2222' / admin@example.com:~/backup-folder
Notes:
'ssh -p 2222'
: use this specific port for SSH connection~/backup-folder
: the copy will go to thebackup-folder
directory inside user's home directory (~
)