How to backup the remote files in Linux / UNIX

htt‮w//:sp‬ww.lautturi.com
How to backup the remote files in Linux / UNIX

To back up files on a remote server, you can use the rsync command with the -e option to specify the remote shell to use for the connection. For example, to copy the /home directory from a remote server to the local /backup directory, you could use a command like this:

rsync -avze ssh user@server:/home /backup

This will connect to the remote server using SSH, copy the /home directory and all of its contents to the local /backup directory, and preserve the permissions and ownership of the files. The -v option enables verbose output, -z enables compression to reduce the amount of data transferred over the network, and -e ssh specifies that the ssh command should be used to connect to the remote server.

Alternatively, you can use the scp command to copy files directly between two remote servers. For example, to copy the /home directory from one remote server to another, you could use a command like this:

scp -r user1@server1:/home user2@server2:/backup

This will connect to the first remote server using the user1 account, copy the /home directory to the second remote server using the user2 account, and save it in the /backup directory. The -r option tells scp to copy the directory and its contents recursively.

It's important to note that these commands only make a copy of the files on the remote server. If you want to create a full system backup, you will need to use a different tool or method. It's also a good idea to regularly test your backups to ensure that they can be restored successfully in case of a disaster.

Created Time:2017-10-16 14:38:44  Author:lautturi