Search This Blog

Tuesday, June 10, 2008

Backing up in Linux

1. Copying Files


The simplest way is to make a backup using the cp command. However, file permissions must be preserved in the process. The following command saves the /home directory to /mnt/bkupdisk device used for backup purposes:

cp -a /home /mnt/bkupdisk

The -a option is used, which is equivanet to the -dpR options. The functions of these options are as follows:

-d -- Never follow symbolic links. The directory is copied as is.
-p -- Preserve the specified attributes (mode, ownership and timestamps)
-R -- Copy directories recursively to back up all subdirectories

The previous command is identical to the following command:

cp -dpR /home /mnt/bkupdisk

The files from this directory that were modified after the backup was performed can be copied with the help of the same command, but with the -u option:

cp -au /home /mnt/bkupdisk

No comments: