Amanda-Users

RE: moved to new disk, now amanda wants to do level 0's on whole system

2003-11-14 16:31:39
Subject: RE: moved to new disk, now amanda wants to do level 0's on whole system
From: Ron Snyder <snyder AT roguewave DOT com>
To: amanda-users AT amanda DOT org
Date: Fri, 14 Nov 2003 13:27:32 -0800
> either.  To copy directory trees, I usually use "( cd /fromdir ; tar
> cf - . ) | ( cd /todir ; tar xpf -)", which preserves modification
> times, and permissions.

I definitely am a fan of tar copying, but wouldn't recommend the above (as
written). The brief explanation is that you really want to replace the ';'
inside of the parens with '&&'.  Below is the more complete example of why
it matters:

## set up the test scenario
[root@hydra tmp]# cd /tmp
[root@hydra tmp]# mkdir foo1 foo2
[root@hydra tmp]# cp /etc/hosts foo1
## make sure there is no /tmp/hosts
[root@hydra tmp]# ls -al hosts
ls: hosts: No such file or directory
## execute the command, but with a typo in the second 'cd' command
[root@hydra tmp]# (cd /tmp/foo1; tar -cf - *) | (cd /tmp/f002; tar -xf -)
bash: cd: /tmp/f002: No such file or directory
## check to see if /tmp/hosts exists now?  Oops.
[root@hydra tmp]# ls -al hosts
-rw-r--r--    1 root     root          153 Nov 14 13:10 hosts
[root@hydra tmp]# ls -al foo2
total 2
drwxr-xr-x    2 root     root         1024 Nov 14 13:10 .
drwxrwxrwt    8 root     root         1024 Nov 14 13:10 ..

For folks new to unix-- replacing the semi-colon after the 'cd' command with
'&&' causes the command following to not get executed.  Logically speaking,
it's a way of saying: Execute this command AND THEN this other command.  If
the first command fails, don't execute the second command.

-ron

<Prev in Thread] Current Thread [Next in Thread>
  • RE: moved to new disk, now amanda wants to do level 0's on whole system, Ron Snyder <=