Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

So I'm doing full backup of my VPS using the following command (as root, of course):

tar czvf 20120604.tar.gz /

Everything seems to be fine, all files seem to appear in the list. The size of archive is 6 Gb and gunzipped version is 11 Gb which includes /home, because I totally have 11 Gb of data on VPS. But when I try actually to unpack archive, or open it using mc or WinRAR, there's no /home folder. And WinRAR tells 20120604.tar.gz - TAR+GZIP archive, unpacked size 894 841 346 bytes. It can't be WinRAR's bug, because when I type tar xzvf 20120604.tar.gz, /home folder isn't unpacked either.

Why is /home folder missing from my archive? And what can I do to include it there?

tar --version outputs the following: tar (GNU tar) 1.15.1

share|improve this question
    
Did you try IZArc? –  Ignacio Vazquez-Abrams Jun 4 '12 at 8:09
    
I just tried it, ho /home folder as well –  Konstantin Pereyaslov Jun 4 '12 at 8:19
    
One question, when you are logged-in as root, can you change the current directory to /home and browse for files? If /home is mounted via NFS (for example), it might not be accessible by root (depending on NFS export options). This is just an idea. –  Huygens Jun 4 '12 at 8:22
    
It's accessible, I may even create a separate archive, using tar czvf home.tar.gz /home and it works exactly as it's supposed to. And somehow /home is included in archive, but not visible by any software, because files outside /home take only about 1 Gb, and tar size is 11 Gb –  Konstantin Pereyaslov Jun 4 '12 at 8:29
1  
Is /home a symlink to another place? (e.g. /usr/local/home/ ). Could winrar break on symlinks, junctions etc? –  Hennes Jun 4 '12 at 8:32

1 Answer 1

I highly suspect the exclusion of the /home directory in your tar'd backup is a result of executing as root (root's home dir being /root/). Glancing at the man page (taken from http://linux.die.net/man/1/tar), the following options may potentially cause/resolve/debug your situation:

  Main operation mode: 
    -C, --directory=DIR
        change to directory DIR 
    -p, --preserve-permissions
        extract information about file permissions (default for superuser) 
    -v, --verbose
        verbosely list files processed 

  Operation modifiers:
    -g, --listed-incremental=FILE
        handle new GNU-format incremental backup 
    -G, --incremental
        handle old GNU-format incremental backup 

  Handling of file attributes: 
    --group=NAME
        force NAME as group for added files 
    --mode=CHANGES
        force (symbolic) mode CHANGES for added files 
    --no-same-owner
        extract files as yourself (default for ordinary users) 
    --no-same-permissions
        apply the user's umask when extracting permissions from the archive (default for ordinary users) 
    --no-xattrs
        Don't extract the user/root xattrs from the archive 
    --numeric-owner
        always use numbers for user/group names 
    --owner=NAME
        force NAME as owner for added files 
    -p, --preserve-permissions, --same-permissions
        extract information about file permissions (default for superuser) 
    --same-owner
        try extracting files with the same ownership as exists in the archive (default for superuser) 
    --xattrs
        Save the user/root xattrs to the archive 

  Device selection and switching:
    --force-local
        archive file is local even if it has a colon 

  Archive format selection:
    -H, --format=FORMAT
        create archive of the given format--FORMAT is one of the following: 
    gnu, oldgnu, pax, posix, ustar, v7, --old-archive, --portability, 
    --pax-option=keyword[[:]=value][,keyword[[:]=value]]... , --posix, 
    -V, --label=TEXT
        <see webpage/ man page for details>

  Local file selection:
    --add-file=FILE
        add given FILE to the archive (useful if its name starts with a dash) 
    -C, --directory=DIR
        change to directory DIR 
    -h, --dereference
        follow symlinks; archive and dump the files they point to 
    --hard-dereference
        follow hard links; archive and dump the files they refer to 
    -K, --starting-file=MEMBER-NAME
        begin at member MEMBER-NAME in the archive 
    --one-file-system
        stay in local file system when creating archive 
    -P, --absolute-names
        don't strip leading '/'s from file names 
    --recursion
        recurse into directories (default) 

  File name transformations:
    --no-anchored
        patterns match after any '/' (default for exclusion) 
    --no-ignore-case
        case sensitive matching (default) 
    --no-wildcards
        verbatim string matching 
    --no-wildcards-match-slash
        wildcards do not match '/' 
    --wildcards
        use wildcards (default) 
    --wildcards-match-slash
        wildcards match '/' (default for exclusion) 

  Informative output:
    --index-file=FILE
        send verbose output to FILE 
    -l, --check-links
        print a message if not all links are dumped 
    --show-defaults
        show tar defaults 
    --show-omitted-dirs
        when listing or extracting, list each directory that does not match search criteria 
    --show-transformed-names, --show-stored-names
        show file or archive names after transformation 
    -v, --verbose
        verbosely list files processed 
    -w, --interactive, --confirmation
        ask for confirmation for every action 

Certainly a LOT to consider, but Linux commands are nothing if not flexible and powerful. I imagine if you study each of these options using a test-box with a limited filesystem structure, running the distribution you intend to employ, you will hit upon the exact combination to include in your script to produce the exact outcome you desire.

For the sake of building communal knowledge, would you please post back with the solution which gives the behavior you desire?

share|improve this answer
    
I know about the manual, I'm not running this in the /root/ directory, I'm running it in /home/usename, so I can download it by ftp. Could it be a reason of exclusion of /home from archive (that's still has it according to it size)? I doubt so –  Konstantin Pereyaslov Sep 15 '12 at 2:11

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.