Posted on

Remote Backup

What is it all about

Just some things which are useful to run backups from a remote machine.

Remote Access with SSH Automatically

When connecting to a remote machine using a script there should be no password popup. This can be simply done by the following procedure:

On the Server:

cd .ssh
ssh-keygen -t rsa  # hit return through all prompts
cat id_rsa.pub >> authorized_keys
chmod 600 authorized_keys
rm id_rsa.pub

On the Client:

cd .ssh
scp myserver.com:.ssh/id_rsa myserver.rsa
chmod 600 myserver.rsa
echo "Host myserver" >> config
echo "Hostname example.com" >> config
echo "IdentityFile ~/.ssh/myserver.rsa" >> config

In the case of Mac OS as client, just download the .rsa file and add it to the key chain:

ssh-add -K /<folder>/myserver.rsa

SSH Auto Login

mysqldump without password

This is done by creating the file ~/.my.cnf in your user directory. The permissions need to be set to 600.

Add this to your .my.cnf file

[mysqldump]
user=
password=