Beginner: Full Linux Server Backup

This has been tested with a working server of Debian5.

Login as root

Make a backup directory. It is best if you have the backup directory on another partition or another hard disk

mkdir -p /backup

Create a backup sh file with arguments to backup the whole system while excluding contents of proc sys dev and backup directory

vi /backup/

tar -cvpf /backup/fullbackup.tar –directory=/ –exclude=proc –exclude=sys –exclude=dev/pts –exclude=backup .

Create a restore sh file which moves the fullbackup.tar file to / and then extracts it

vi /backup/

mv /backup/fullbackup.tar /fullbackup.tar

tar -xvpf /fullbackup.tar

Change the file permissions to make it executable

chmod -R 750 /backup

Add an argument to crontab to make it run at 22:10 daily.

crontab -e

10 22 * * * /backup/


To restore this backup, install a minimal version of the same linux flavor and then run /backup/

Read More

Reverse SSH Port Forwarding

The way the network configuration has been done at my office makes it impossible to do a port forwarding to access a specific machine outside the network. I figured out that it could be possible to perform a reverse ssh port forwarding.

1. You need a server machine that will accept ssh connections : Install ubuntu(because its the easiest to install) on a machine at home. Make sure you do a port forwarding on your router if you have to and map a dynamic dns from on that machine.

apt-get install openssh

2. The host machine at my office(Linux Based) would need to verify the connection to the outside server every time because the IP address of the office is dynamic and the server at your place is not on all the time.

Write a small script in /home/username that would do the following:

COMMAND=”ssh -N -f -R 2210:localhost:22”
pgrep -f -x “$COMMAND” > /dev/null 2>&1 || $COMMAND

Add that script to your crontab(runs it every 5 minutes)

*/5 * * * * /bin/sh /home/username/

3. Perform RSA key pairs

Because the two machines need to authenticate before communicating with each other, we will need to make an automatic login via rsa public/private key pairs.

ssh-keygen -t rsa (Run this on the host machine)

when all steps of the keygen are done,(Press enter until its over, no need to input anything)

cd ~/.ssh/


And you’re done. You should now be able to login to the host machine by login in on the server machine and running “ssh -p 2210 localhost” when logged in as root.

Read More