Backup DSL |
Desktop Training - DSL |
Chapter 13: BackupsBacking up data is a critical aspect of all computer use. Linux provides many easy methods for backing up data. The user should consider backing up all data that cannot be easily recovered quickly. That includes the /home directory which is the location of user data. You may also want to backup the /etc directory as this is where the majority of configuration files are located. Backup/RestoreThe Backup/Restore feature is a great way to create a backup for changes that you make to your system. You need to have a partition that you an save your backup to. A file called backup.tar.gz will be saved to that directory. When the system shuts down you will see a message that your backup is being saved. When you startup you will see a restore taking place.
Select the Backup/Restore button on the DSLPanel and then select the partition that you will save the backup to.
If you want to discontinue a backup select None and it will cancel the current location.
The key to the backup process is choosing which things to be backed up, as you do not want to backup everything. The file .filetool.lst is a list of the specific things to backup. Below are the default settings of .filetool.lst opt/ppp opt/bootlocal.sh opt/powerdown.sh opt/.dslrc home/dsl If you wanted to add specific directories or files you can edit the file and add scripts as seen below. Notice no preceding / in the config file. opt/scripts home/dsl/.fluxbox/menu home/dsl/.xinitrc Note that one of the files included in the .filetool.lst is the bootlocal.sh found in /opt that enables you to save your network configuration. Backing Up Network ConfigurationWhen the system starts you may want to run scripts to setup your preferences. These preferences may be setup in /opt/bootlocal.sh. This script executes as the last step to loading the desktop so you can enter scripts that you want to run here. In this example you will see how to setup your network card configuration so it will load each time at bootup. First set your network preferences in this file, notice this is for the first network card eth0. Use an editor like nano or vi to make the changes. /etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE=eth0 IPADDR=192.168.5.23 This example is using a static IP Address. The static IP Address is 192.168.5.23 in the example. Once that file is configured then edit your /opt/bootlocal.sh file as root. 1. #!/bin/bash Lines 4 and 5 have been added (don't add the numbers). Line 4 executes the settings for the network card and line 5 initiates the network card. Follow this same procedure for executing any other scripts at boot. Burning CDsIn order to burn CDs for a backup select Apps / Tools and CD Burn App on the Menu. When this program opens it will give you a menu to determine what you would like to do. The Options link will take you to this screen where you may edit options as you need. What you see in the illustration are the default settings.
The process of burning a backup CD is fairly straight forward. Choose Add files so you may select all those files that you would like to burn. Click on the files you need.
When you view files to burn you may notice that there seems to be a lot more files than you had seen before. The difference is that there are a number of hidden files in each directory which are usually system files or settings. These hidden files all start with a “dot”. Notice in the example that you can see these hidden files.
Once you have selected all of the files you want to burn the next step is to select the “Create Image”. This will prepare the CD to be burned. Once that is selected then choose “Write Data CD” and the burn process will begin. The CD burning process will burn at the speed of your CD Burner.
This will then complete the process. Hard Drive BackupsThe cost of hard drives continues to drop and so they make great backup options. The key to backing up to a hard drive is to have two hard drives. It is not too productive to backup on the same hard drive as your data because if that drive fails you will lose it all. One way to use a second hard drive is to create a separate partition on the second drive for backups called /bk for instance. Then use the cp command. Here is an example with two hard drives where the second hard drive is one partition /bk. This is a quick command: cp -R /home /bk Notice that the copy command, cp is used with the recursive option -R which copies over all the subdirectories as well. Creating a Backup With TarThe tar program is on all Linux systems and provides a way to create a backup of a directory quickly. The format for tar is: tar options destination source It is easy to get the destination and source confused so double check it. If the user mary wanted to back up her home directory to a backup partition called /bk this would be the command: tar cvf /bk/mary_bk.tar /home/mary Notice the options are: c create an archive v verbose and list all the activity f place the archive in a file Now if there was a system crash and mary needed to retrieve that tar file and expand it here is the command to do that: tar xvf /bk/mary_bk.tar / The options are: x extract the files v verbose f read from the file Notice that if mary lost her directory the whole thing could be restored by indicating where to restore it and that is why the / is important because it would recreate /home/mary from the / directory. Simple Scripts This script will backup the /home directory and create a tar file with a timestamp. This will give you the ability to backup as often as needed. With the low cost of hard drives this could be a usable option. ####################################### #!/bin/sh
######################################## Using rsync rsync script This script will sync the /home where user mail is kept to a directory on a separate drive. One the file is synced then it will be backed up with a tar command in the example above. ######################################## #!/bin/sh # /usr/bin/rsync -a - -verbose - -stats /home /bk/home if [ $? -ne 0 ]; then FAILED=1 fi ######################################## Crontab By using crontab -e you will be able to setup cron jobs that will run the two scripts above as often as you need. 17 8-17 * * * /root/rsync.sh
47 8-17 * * * /root/bk.sh
|