Home > linux > Backup Remote Linux Servers

Backup Remote Linux Servers

Here is small script to backup multiple remote servers to local machine and then delete remote file after the operation.

You need ssh key setup with remote machines for the script to login.

Of course you can use the same script(after desired modification) to automate any operation on remote machines from your local machine cron.


TIMESTAMP=`date +%Y%m%d_%H%M`

for i in $hosts;
  echo $i
  ssh $i tar -czvpPf /root/mysqlbackup_"$TIMESTAMP".tar.gz /var/lib/mysql/
  scp root@$i:/root/mysqlbackup_"$TIMESTAMP".tar.gz /mnt/mysqlbackup/mysql_"$FILENAME".tar.gz
  ssh $i rm -f /root/mysqlbackup_"$TIMESTAMP".tar.gz
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: