[Novalug] Thanks and November
igor_birman at yahoo.com
Fri Oct 14 21:52:06 EDT 2011
Since you asked, I want to write down what I do for backup. There is nothing you can do with your computer than keep your data backed up, so I will try to go through it step by step. There are lots of other ways to do this, but here is how it works in my house. I have two linux servers, sagan and hubble. Both are running Ubuntu. Sagan is the main server, Hubble is the backup.
Everyone in the house has an account on Sagan, and I tell them to save their stuff there. If it isn't saved there, I don't want to hear any whining.
I am using rsync for backup, so SSH must be installed on both servers - sudo apt-get install sshd.
One thing about backups is that there are many ways for backups to fail, so whatever solution you use for backups, you must have some way to check and see if it is working. While writing this email I realized that Hubble is down - power went out yesterday and it is not running. I just went downstairs and hit the power button. Sagan is on a battery backup, but Hubble isn't...
Another thing I want to mention is that it is a good idea for servers to have fixed IP addresses. You always want to be able to find your server even if something else breaks. Ubuntu does not make it easy to set up a fixed IP address, so it is best to reserve an address on your router... (a topic for another discussion?)
On Sagan, I configured samba to act as a file server. There are some tricks to configuring Samba but I can save those for another email. I have several folders that I would like to have backed up, let's just say I want to backup /home/igor and /home/pictures
On Hubble, I created a folder called /home/backup. I want /home/backup/igor and /home/backup/pictures to mirror the corresponding folders on Sagan. You always want to make sure your backup folders are obviously backup folders - if I just had /home/igor on Hubble it would be easy to mistake it for the real folder (yes I speak from experience)..
I created an account called "igor" on both servers with the same password. You could set up a domain controller so you only have to set up accounts on one server, but, again, that's a topic for another discussion.
Since the backup has to be automated, I don't want to have to enter a password each time. I configured ssh on Hubble to not require a password using instructions here: http://linuxproblem.org/art_9.html
I could have set up the backup to push or pull. I chose to run the backup script on Hubble and pull the files from Sagan.
The rsync commands I use to run the backup are:
rsync -av igor at sagan:/home/igor /home/backup > ~backup.log
rsync -av igor at sagan:/home/pictures /home/backup >> ~backup.log
You should run these commands manually to make sure they work, and then check the results. The first time it will take a while, but after that rsync is very fast as it only copies things that have changed.
The command to set up a scheduled job under linux is "crontab". Type crontab -e in order to edit the cron table. Remember that "sudo crontab -e" will edit root's crontab, while "crontab -e" will edit your crontab - either is fine as long as you know the difference. You must have authority to access all the files you will be backing up. In my case igor is a member of group users, and all files on /home/sagan also belong to group users. If you don't have the correct permissions, you will see errors from the rsync command above, and will need to resolve them.
Crontab has 6 columns - minute, hour, day of month, month, day of week, and command. You can put in a comment starting with a #, and in every crontab file I use, the first line is a comment reminding me of what each column does. I want my backups to run at 2AM, so I have the following in my crontab:
# m h dom mon dow command
00 02 * * * rsync -av igor at sagan:/home/igor /home/backup/ > ~/backup.log
10 02 * * * rsync -av igor at sagan:/home/pictures /home/backup/ >> ~/backup.log
I enter this by typing crontab -e, entering the commands above, and saving the file. In the morning, I should have a file called backup.log in my home folder, and I can look at it to check if the backup worked.
It would be useful to set up something to email the backup file to myself, or even email it only if there are errors, but that can be left for another discussion.
If you can go through the steps above, and see the backup.log in the morning, then you have successfully set up a backup!
I saved the above on my wiki at http://cyberigor.com/pmwiki/pmwiki.php?n=Main.MyLinuxBackup. Please try it out and let me know what works and what doesn't so I can update it.
From: Nino R. Pereira <ninorpereira at gmail.com>
> A longstanding question I have is: where do I add a backup command so that
> a backup runs at say 3 am every day? Very simple things like this will
> be very helpful to me.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Novalug