Saturday 22 October 2011

Backup and Recovery

Create a folder
for EX:-- /myfolder

[root@tsmservertest ~]# mkdir /myfolder
[root@tsmservertest ~]# cd /myfolder/

Now create Some files and folders inside it.

[root@tsmservertest myfolder]# mkdir dir1
[root@tsmservertest myfolder]# touch 1 songs tom_file
[root@tsmservertest myfolder]# ls
1  dir1  songs  tom_file


Use the tar command to tape archive the folder

[root@tsmservertest ~]# tar -cvf /opt/myfolder.tar /myfolder
tar: Removing leading `/' from member names
/myfolder/
/myfolder/tom_file
/myfolder/dir1/
/myfolder/songs
/myfolder/1

[root@tsmservertest ~]# cd /opt/
[root@tsmservertest opt]# ls -l
total 12
-rw-r--r-- 1 root root 10240 Oct 22 13:01 myfolder.tar


To Create a tar file with zip

[root@tsmservertest opt]# cd
[root@tsmservertest ~]# tar -cvzf /opt/myfolder.tar.gz /myfolder/
#########OUTPUT#############
tar: Removing leading `/' from member names
/myfolder/
/myfolder/tom_file
/myfolder/dir1/
/myfolder/songs
/myfolder/1
[root@tsmservertest ~]# cd /opt/
[root@tsmservertest opt]# ls -l
total 16
-rw-r--r-- 1 root root 10240 Oct 22 13:01 myfolder.tar
-rw-r--r-- 1 root root   194 Oct 22 13:10 myfolder.tar.gz


To View the contents of the tar file without extracting

[root@tsmservertest opt]# tar -tvzf /opt/myfolder.tar.gz
drwxr-xr-x root/root         0 2011-10-22 12:58 myfolder/
-rw-r--r-- root/root         0 2011-10-22 12:58 myfolder/tom_file
drwxr-xr-x root/root         0 2011-10-22 12:58 myfolder/dir1/
-rw-r--r-- root/root         0 2011-10-22 12:58 myfolder/songs
-rw-r--r-- root/root         0 2011-10-22 12:58 myfolder/1

To remove the folder

[root@tsmservertest ~]# rm -r /myfolder/
rm: descend into directory `/myfolder'? y
rm: remove regular empty file `/myfolder/tom_file'? y
rm: remove directory `/myfolder/dir1'? y
rm: remove regular empty file `/myfolder/songs'? y
rm: remove regular empty file `/myfolder/1'? y
rm: remove directory `/myfolder'? y
[root@tsmservertest ~]# cd /


To extract the tar file or recovery the data


[root@tsmservertest /]# tar -xvzf /opt/myfolder.tar.gz
myfolder/
myfolder/tom_file
myfolder/dir1/
myfolder/songs
myfolder/1


After extracting see the contents inside the folder


[root@tsmservertest /]# ls /myfolder/
1  dir1  songs  tom_file




0 comments:

Post a Comment

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Affiliate Network Reviews