Operating System - Linux
1755067 Members
3433 Online
108829 Solutions
New Discussion юеВ

Copy filesystems with tar

 
SOLVED
Go to solution
Alfonso_4
Advisor

Copy filesystems with tar

Hi, I need to copy one filesystem to other filesystem (backup but not on tape) with tar command on linux red hat 7.1. And I used this command :
cd sourcedir; tar -cf - . | (cd targetdir; tar -xf -)

But, I received this error with some directories:
time stamp 2007-02-04 13:56:12 is 175265582 s in the future.

I need a tar parameter or another command (dump, cpio) that ignore dates and time when its copying files.

I used --atime-preserve tar parameter but it didn't work or I don't know how to use it.

I will appreciate any help, thank you.

6 REPLIES 6
Charles Slivkoff
Respected Contributor

Re: Copy filesystems with tar

As far as I can tell, the message from tar is merely a warning. Add "2>/dev/null" to send it to the bit-bucket.



Bernie Vande Griend
Respected Contributor

Re: Copy filesystems with tar

You could it with dump, tar, or cpio. The message you got with tar was just a warning.

To copy with dump:
The only obstacle is the that it will include the full path in the restore. Here's an example assuming copying of /home to /home2

dump -0 -f - /home | (cd /home2; restore -x -f -)

This works well, except that the home directory will appear under /home2 and then you just need to use move to rename it to where it should be.

CPIO: Example where permissions are preserved:

find . -depth -print |
cpio -plvdmu /outputdest

It will copy the directory you are in to outputdest and preserve everything.

For tar, your command is fine, except that I'd add a -p on the untar for preserve:

tar -cf - . | (cd targetdir; tar -xpf -)



Ye who thinks he has a lot to say, probably shouldn't.
Chris Calabrese
Valued Contributor

Re: Copy filesystems with tar

tar and cpio are designed to copy files, not filesystems. This is an important distinction here.

If you want to make backups of filesystems, use dump, which is designed exactly to solve this problem.

In your case, you might even consider just using dd to make an exact image of the filesystem. It can't do incremental backups, but it doesn't sound like that's what you're after.
Brainbench MVP for Unix Administration and Internet Security, SANS Review Editor, and Center for Internet Security HP-UX Benchmark project leader
Bill Thorsteinson
Honored Contributor

Re: Copy filesystems with tar

I have attached a script I use to move directories into
filesystems. As is the script requires the destination
be empty. You will likely want to change this.
The extract is verbose, and preserves permissions.

While the timestamp in the future message is just a
warning, it is a symptom of a possibly serious problem.
If the problem persists and applies to different files
you have a time syncronization problem.

If your system is ever compromized, forget the
timestamps in the log files. Setup xntpd, and
syncronize all the system that can write to this
file system.
Alfonso_4
Advisor

Re: Copy filesystems with tar

Hi, thanks for your help. Now my problem is that Im trying to use dump to copy a filesystem shared with NFS to a local filesystem, when I type "dump -0 -f - source | (cd destination; restore -x -f -)", this is the error message:

"No such file or directory while opening filesystem

restore: Tape is not a dump tape".

Thanks.
Bernie Vande Griend
Respected Contributor
Solution

Re: Copy filesystems with tar

Oops, don't believe dump can do that. The man page for dump says:
"It might be considered a bug that this version of dump can only handle ext2 filesystems. Specifically, it does not work with FAT filesystems."

Since the filesystem you are trying to dump is remote (NFS), this version of dump can't handle it.
You're going to have to use cpio, tar, or dd if you want to do it locally.
Ye who thinks he has a lot to say, probably shouldn't.