1834499 Members
3134 Online
110068 Solutions
New Discussion

tar backup

 
Michael Murphy_2
Frequent Advisor

tar backup

OK - here is an easy one (I think) - I am trying to make a tar (or cpio) backup of a filesystem that has other filesystems under it. Is there an option to keep the file backup only to files in a given filesytem even if another filesystem is a subdirectoy to the upper level filesystem? Thanks
8 REPLIES 8
Yogeeraj_1
Honored Contributor

Re: tar backup

hi,

did you try something like:

cd /
tar -cvf /tmp/FILES.TAR ./*.*


kind regards
yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
Michael Steele_2
Honored Contributor

Re: tar backup

Hi Michael:
What Yogeerai provided it the way to do it. And its a relative backup and restore vs. an absolute. What's the difference? The pathway of the archive that your creating.

./* = relative

/dir/dir/* = absolute

If you absolute restored and the mount point didn't exist then you'd be making a sub directory under / (root) and quickly max out.
Support Fatherhood - Stop Family Law
Michael Murphy_2
Frequent Advisor

Re: tar backup

ok - just to be clear - are you saying that a tar -cvf of say for instance / will NOT backup up files in /tmp if /tmp happens to be a filesystem under /?
James R. Ferguson
Acclaimed Contributor

Re: tar backup

Hi Michael:

GNU 'tar' has far better options available than the standard 'tar'.

In particular, you note that you don't want to cross mountpoints. That is, if you are copying files from '/', you don't want to descend into '/usr', '/tmp', etc.

To control this, begin with:

# find / -xdev -type f > /tmp/myfiles

# tar -cv -T /tmp/myfiles -f /archivefile_or_tape

Using the standard HP-UX 'tar' you can (sometimes) do:

# tar -cvf /archivefile_or_tape `cat /tmp/myfiles`

The problem, however, is that the shell will expand the 'cat /tmp/myfiles' into a list and can potentially yield an "argument too big" error.

If you are not dedicated to using 'tar', I would suggest 'fbackup'. Of course, this is HP-UX proprietary and limits you to archiving and extracting on HP servers.

Regards!

...JRF...
Geoff Wild
Honored Contributor

Re: tar backup

On linux I use tar the same way as James - make a list of files you want backed up.

Example:

TARFILE=`date |awk '{print ($1)}'`.tar

tar -cf /home/backups/$TARFILE `cat /root/backupfiles` >>$LOGFILE 2>&1

cat /root/backupfiles
/bin
/boot
/dev
/etc
/home/a2b1002
/home/a2b1003
/home/aquota.user
/home/ftp
/home/httpd
/home/info
/home/webmaster
/initrd
/lib
/misc
/mnt
/opt
/root
/sbin
/scripts
/tmp
/usr
/var

As you see, my tarball goes into /home/backups but that dir does NOT get backed up (else I would be backing up my backup).

Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Sp4admin
Trusted Contributor

Re: tar backup

hello,

Copy a directory using TAR

tar cf - .|(cd /tmp/tar.test; tar xf -)

* Note you must be root. You must cd to the directory and then issue the command.
Dennis Handly
Acclaimed Contributor

Re: tar backup

>James: GNU 'tar' has far better options available than the standard 'tar'.

pax(1) has a -X option to do this and can write cpio or tar archives.

So: pax -w -X -f foo.tar /

>The problem is that the shell will expand the 'cat /tmp/myfiles'

cpio takes its list from stdin.
James R. Ferguson
Acclaimed Contributor

Re: tar backup

Hi:

> Dennis: pax(1) has a -X option to do this and can write cpio or tar archives.

Thanks, Dennis, I guess I need to examine 'pax' in more detail. It's ideal for handling the restoration of 'tar' archives created with absolute paths to a relative directory but I frankly had not investigated its use in creating 'tar' archives in the first place.

I would note that AIX implements a GNU-like ability to use a file to specify the 'tar' archive. It's too bad HP doesn't choose to add this enhancement too.

Regards!

...JRF...