Today I am discussing how to take backup of directory without specifying absolute path.
Create tar backup with and without absolute path. There are different way of creating tar backup.Some time some strange things happened when Linux/Unix admin extract tar backup and that backup not got extracted to correct location.
Why backup not extracted to correct location ??
Answer to this query is command which was used while creating tar backup ,if admin used correct command while creating tar backup then he will not face any problem.
What will happen after extracting and where backup will be extracted ?? also we will see how to take backup of soft link in tar backup and preserve permission.
Linux/Unix admin sometime need to create tar backup and restore it to on other server where data need to extract at different path.
So let see how admin can create tar backup using correct command .
what are the correct way of creating tar backup ??
There are 2 ways to create tar backup??
1. With absolute path
2. Without Absolute path
While creating tar backup don't mention absolute path, if Linux-UNIX admin want to extract tar backup at different path, because if admin create tar backup using absolute path then while extracting backup at target location OS will try to find same path and if it will not able to find path then it will extract to current directory and while creating tar backup admin specified full path of directory then it will create whole structure of directory from parent directory.
So what will be solution for this ??
Solution is while creating backup go to path where target directory
and execute command to create tar backup
#cd /required-path // where test dir is present
#tar -zcvf test.tar.gz test
How to extract this backup to destination server at any path.
At destination ,Go to target path and execute following command
#tar -zxvf test.tar.gz // extarct to current directory.
tar -zxvf test.tar.gz -C /destination_directory //extract to specific directory
Some example of tar command.
if admin want to preserve symbolic link and preserve original permission he can use "h" and "p" flag.
h - preserve symbolic link
p- preserve original permission.
ex. tar -cvhf
*** if admin create tar backup with absolute path then at target server there must be absolute path exist if absolute path not exist it will extract backup to current path where he extracting tar file and create same directory structure in current path.
No comments:
Post a Comment