Setting up Slackware 13 (64-bit) (part 3)

Make your server trust your laptop+user:

#su - "your username here"

$ssh-keygen -t rsa

$scp ~/.ssh/id_rsa.pub "remote_username"@"host_name":"target_filepath_for_key_on_the_server"

Now ssh into your server:

$ssh "remote_user"@"host_name"

$cd ~/.ssh

Insert your laptop’s public key in the authorized keys list:

$cat "target_filepath_for_key_on_the_server" >> authorized_keys

Try ssh-ing your server again (this time you should not need to type a password:

$ssh "remote_user"@"host_name"

Create an alias for your server:

#nano /etc/ssh/ssh_config

and add thisĀ  (customize it, please):

Host linode
HostName portnumber53.com
KeepAlive yes
User httpd
Compression yes

Now you should be able to ssh into your server like this:

$ssh linode

Now use this nice backup script:

#!/bin/bash
pid=/tmp/linode.pid
TODAY_FOLDER=/home/backup/`date +%Y-%m-%d --date "0 day ago"`/linode
YESTERDAY_FOLDER=/home/backup/`date +%Y-%m-%d --date "1 day ago"`/linode

if [ -e $pid ]
then
echo "Still running..."
else
touch $pid
if [ ! -d $TODAY_FOLDER ]; then
mkdir -p $TODAY_FOLDER
echo "copying..."
cp -alv $YESTERDAY_FOLDER/. $TODAY_FOLDER
fi

rsync --bwlimit=100 --force --no-p --progress --delete-before -aze ssh linode:~/ $TODAY_FOLDER
rm $pid
fi

and you will have full backups (while preserving spaces as the cp command creates hardlinks) daily

Tagged , , . Bookmark the permalink.

Leave a Reply