Managing Unix File System Backup
At some point of time, you probably need to backup your application files data on your system.
tar is always the best command used in Unix for file archiving or backup.
All you need to create an archive files was by following the command as below: –
$ tar -cvf <filename> <files to backup>
Just an example, if we want to backup all the files within the /oracle directory then we can use the tar command as below: –
$ cd /oracle/..
$ tar -cvf oracle.tar /oracle
It was always advisable to tar the directory on top of directory itself, where you can untar it to any location you like in the future.
The -v option was for “verbose” and we will see a long list of files in the screen when they are added to the archive file.
If we want to have compression when executing tar command, then you may include the -z option which will create .tgz archive file in compressed mode.
$ tar -cvzf oracle.tgz /oracle
Note that Unix doesn’t care the naming of your archive file, but it’s recommended to use .tgz or .tar.gz after compressing the tar file with -z option.
In case you want to backup your file into tape, and the tape was on /dev/st0 mount point in example: –
$ tar -cvf /dev/st0 /oracle /home
Managing Unix File System Recovery
You can extract files from a simple uncompressed .tar file by invoking tar command with -xvf option.
How about uncompress the files from .tgz extension or unzipping them? You may use the -z option again the the tar command as below: –
In our backup just now, we do have create backup of /oracle and /home into tape on /dev/st0. If you want to recover your directory from /dev/st0 then you may run the tar command as below: –
The -p option in the tar command was to preserve the permissions of the files as they were stored in tape. Let say if I just want to restore /home from /dev/st0 then what I need to do was to add the name after the extract command.
$ tar -xvpf /dev/st0 /home
Next» How To Verify And Test Unix File Archive/Backup