Backup and entire dir using tar?

R. Mattes rm at mh-freiburg.de
Thu Jan 20 01:06:58 UTC 2005


Senectus . wrote:

>I want to tar up an entire directory and all the sub dir's in it as by
>keeping all the permissions and structures as is..
>I'm having a bugger of a time figuring out how it works.. whats the
>best practice for tar.gz a dir with all sub dir for later restore..?
>
>  
>

Hmm, it would actually be very helpfull if you could tell us _what_ exactly
you tried and what didn't work out the way you expected it.
To backup a directory tree you can just do:

 $ tar cvzf   backup.tar.gz my_importamt_data/

Where:  - 'backup.tar.gz' is the name of the archive you want to create
               - 'my_importamt_data/'  is the directory you want to backup.
               - tar's options i used:
       
                        c  Create a new archive
                        v  Verbose (so we can see what's going on)
                        z  use gZip compression (saves space)
                        f  the Filename of the archive to create
 Note: the options do not start with the usual  dash, it's 'cvzf' and 
_not '-cvzf'
 The 'f' option obviously has to go last (just in front of the archive 
name) - any other
 option can go anywhere ...
If you prefer the more modern bzip compression you need to substitute 
'z' with 'j' (we are
running out of options :-)

 HTH Ralf Mattes






More information about the ubuntu-users mailing list