Backups are important but sometimes files are just too big to save to your computer or to the server that you’re trying to backup. This is when you might want to backup to another server through ssh.
Here is a command that allows you to backup a folder to another server:
nice tar zcvf - /home/server | ssh -p 1234 email@example.com "cat > ~/backup.tar.gz"
nice asks it not to interfere with other processes running on the server.
/home/server is the folder you want to backup.
1234 is the ssh port on the destination server. You can leave the -p 1234 part out if it uses the default port 22.
The user on the destination server must have their shell set to /bin/bash in order to login through ssh like this, in Ubuntu Linux at least.
cat will write the input to the backup.tar.gz file in the user’s home folder on the destination server.
You might get a message about accepting the login the first time so you can just say yes to that and then it should backup everything onto the destination server.
If it says you don’t have permission then user might not have /bin/bash set as their shell so they won’t be able to login.
If you keep trying to connect too many times it might ban your IP on the destination server’s firewall, especially if you don’t get the right port or user. If you can’t access the server properly it may only show a few files and then pauses and no file will appear on the destination server.
You’ll know if it’s transferring to the destination server if the backup file appears in the user’s home folder. It should appear immediately as you run the command, otherwise you may have a connection issue.