Results 1 to 2 of 2
Hello all,
In my directory u01 , I have 2 subdirectories (u04 and u05)
In subdirectory u05 are two links to other directories.
See the listing:
[root u01]# ls -las
...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 05-06-2012 #1Just Joined!
- Join Date
- May 2012
- Posts
- 1
Symbolic links in tar file
Hello all,
In my directory u01 , I have 2 subdirectories (u04 and u05)
In subdirectory u05 are two links to other directories.
See the listing:
[root u01]# ls -las
total 40
8 drwxr-xr-x 4 root root 4096 May 5 08:40 .
8 drwxr-xr-x 5 root root 4096 May 5 08:53 ..
8 drwxr-xr-x 2 root root 4096 May 5 08:17 u04
8 drwxr-xr-x 2 root root 4096 May 5 08:35 u05
8 -rw-r--r-- 1 root root 8 May 5 08:18 x.x
[root u01]# ls -las u04 u05
u04:
total 24
8 drwxr-xr-x 2 root root 4096 May 5 08:17 .
8 drwxr-xr-x 4 root root 4096 May 5 08:40 ..
8 -rw-r--r-- 1 root root 8 May 5 08:17 a.a
u05:
total 24
8 drwxr-xr-x 2 root root 4096 May 5 08:35 .
8 drwxr-xr-x 4 root root 4096 May 5 08:40 ..
4 lrwxrwxrwx 1 root root 9 May 5 08:40 u02 -> ../../u02
4 lrwxrwxrwx 1 root root 9 May 5 08:40 u03 -> ../../u03
[root u01]#
I want to make a backup of u01 with the tar command.
The problem are the symbolic links in u05
My work-around: two tar files, one with symbolic links and one with the files
The commands I used:
[root u01]# find -L . -xtype l | xargs tar cf ../u01_10.tar
[root u01]# tar -chf ../u01_11.tar *
The content of the tar files:
[root u01]# tar -tvf ../u01_10.tar
lrwxrwxrwx root/root 0 2012-05-05 08:40:52 ./u05/u02 -> ../../u02
lrwxrwxrwx root/root 0 2012-05-05 08:40:52 ./u05/u03 -> ../../u03
[root u01]# tar -tvf ../u01_11.tar
drwxr-xr-x root/root 0 2012-05-05 08:17:14 u04/
-rw-r--r-- root/root 8 2012-05-05 08:17:14 u04/a.a
drwxr-xr-x root/root 0 2012-05-05 08:35:08 u05/
drwxr-xr-x root/root 0 2012-05-05 08:18:13 u05/u02/
-rw-r--r-- root/root 8 2012-05-05 08:18:13 u05/u02/b.b
drwxr-xr-x root/root 0 2012-05-05 08:18:25 u05/u03/
-rw-r--r-- root/root 8 2012-05-05 08:18:25 u05/u03/c.c
-rw-r--r-- root/root 8 2012-05-05 08:18:38 x.x
If I remove everything in u01 and restore the tar files, I have all my files restored.
Removing all files;
[root u01]# rm -rf * ../u02/* ../u03/*
[root u01]# ls -las * ../u02/* ../u03/*
ls: *: No such file or directory
ls: ../u02/*: No such file or directory
ls: ../u03/*: No such file or directory
Restoring the files:
[root u01]# tar -xvf ../u01_10.tar
./u05/u02
./u05/u03
[root u01]# tar -xvf ../u01_11.tar
u04/
u04/a.a
u05/
u05/u02/
u05/u02/b.b
u05/u03/
u05/u03/c.c
x.x
The listing after restore:
[root u01]# ls -las
total 40
8 drwxr-xr-x 4 root root 4096 May 5 09:13 .
8 drwxr-xr-x 5 root root 4096 May 5 09:10 ..
8 drwxr-xr-x 2 root root 4096 May 5 08:17 u04
8 drwxr-xr-x 2 root root 4096 May 5 08:35 u05
8 -rw-r--r-- 1 root root 8 May 5 08:18 x.x
[root u01]# ls -las u04 u05 ../u02 ../u03
../u02:
total 24
8 drwxr-xr-x 2 root root 4096 May 5 08:18 .
8 drwxr-xr-x 5 root root 4096 May 5 09:10 ..
8 -rw-r--r-- 1 root root 8 May 5 08:18 b.b
../u03:
total 24
8 drwxr-xr-x 2 root root 4096 May 5 08:18 .
8 drwxr-xr-x 5 root root 4096 May 5 09:10 ..
8 -rw-r--r-- 1 root root 8 May 5 08:18 c.c
u04:
total 24
8 drwxr-xr-x 2 root root 4096 May 5 08:17 .
8 drwxr-xr-x 4 root root 4096 May 5 09:13 ..
8 -rw-r--r-- 1 root root 8 May 5 08:17 a.a
u05:
total 24
8 drwxr-xr-x 2 root root 4096 May 5 08:35 .
8 drwxr-xr-x 4 root root 4096 May 5 09:13 ..
4 lrwxrwxrwx 1 root root 9 May 5 09:13 u02 -> ../../u02
4 lrwxrwxrwx 1 root root 9 May 5 09:13 u03 -> ../../u03
Want I want is one tar backup file instaed of two.
I tried:
[root u01]# find -L . -xtype l | xargs tar cf ../u01_20.tar
[root u01]# tar -rhf ../u01_20.tar *
[root u01]# tar -tvf ../u01_20.tar
lrwxrwxrwx root/root 0 2012-05-05 09:13:42 ./u05/u02 -> ../../u02
lrwxrwxrwx root/root 0 2012-05-05 09:13:42 ./u05/u03 -> ../../u03
drwxr-xr-x root/root 0 2012-05-05 08:17:14 u04/
-rw-r--r-- root/root 8 2012-05-05 08:17:14 u04/a.a
drwxr-xr-x root/root 0 2012-05-05 08:35:08 u05/
drwxr-xr-x root/root 0 2012-05-05 08:18:13 u05/u02/
-rw-r--r-- root/root 8 2012-05-05 08:18:13 u05/u02/b.b
drwxr-xr-x root/root 0 2012-05-05 08:18:25 u05/u03/
-rw-r--r-- root/root 8 2012-05-05 08:18:25 u05/u03/c.c
-rw-r--r-- root/root 8 2012-05-05 08:18:38 x.x
If I restore this file, directories are made instead of symbolic links in subdirectory u05:
[root u01]# rm -rf * ../u02/* ../u03/*
[root u01]# tar -xvf ../u01_20.tar
./u05/u02
./u05/u03
u04/
u04/a.a
u05/
u05/u02/
u05/u02/b.b
u05/u03/
u05/u03/c.c
x.x
The listing:
[root u01]# ls -las u04 u05 ../u02 ../u03
../u02:
total 16
8 drwxr-xr-x 2 root root 4096 May 5 09:22 .
8 drwxr-xr-x 5 root root 4096 May 5 09:19 ..
../u03:
total 16
8 drwxr-xr-x 2 root root 4096 May 5 09:22 .
8 drwxr-xr-x 5 root root 4096 May 5 09:19 ..
u04:
total 24
8 drwxr-xr-x 2 root root 4096 May 5 08:17 .
8 drwxr-xr-x 4 root root 4096 May 5 09:23 ..
8 -rw-r--r-- 1 root root 8 May 5 08:17 a.a
u05:
total 32
8 drwxr-xr-x 4 root root 4096 May 5 08:35 .
8 drwxr-xr-x 4 root root 4096 May 5 09:23 ..
8 drwxr-xr-x 2 root root 4096 May 5 08:18 u02
8 drwxr-xr-x 2 root root 4096 May 5 08:18 u03
So, I want one tar backup file instead of two.
My questions:
- can I make one tar backup file? If yes, what do I have to do
- Is tar the right command to do this, or do I have to use another command?
with regards.
- 05-06-2012 #2Linux User
- Join Date
- Jan 2005
- Location
- Saint Paul, MN
- Posts
- 398
Simple solution:Code:/ /x.x / / / / /a.a / /u04/ /u01/ / /u05/ somewhere/ / /u02->./../../u02 / / /u03->./../../u03 / /u02/ / /b.b / /u03/ /c.c
Code:cd somewhere tar cf backup_u01_u02_u03.tar u01 u02 u03


Reply With Quote
