Results 1 to 9 of 9

Thread: backup

  1. #1
    Join Date
    Mar 2004
    Posts
    999

    backup

    Hi

    I want to backup a whole directory located in /home/usr/local/ through SSH, whats the command to zip a whole directory along with its contents?

    Thanks

  2. #2
    Join Date
    Jun 2003
    Location
    UK
    Posts
    6,601
    tar -jxf /path/to/archieve /home/usr/local

    Rus
    Russ Foster - Industry Curmudgeon

  3. #3
    Join Date
    Mar 2004
    Posts
    999
    [email protected] [/usr/local/apache/htdocs]# tar -jxf /home/[acct]/ /usr/local/apache/htdocs/search22
    tar (child): /home/[acct]/: Cannot read: Is a directory
    tar (child): At beginning of tape, quitting now
    tar (child): Error is not recoverable: exiting now

    bzip2: Compressed file ends unexpectedly;
    perhaps it is corrupted? *Possible* reason follows.
    bzip2: Invalid argument
    Input file = (stdin), output file = (stdout)

    It is possible that the compressed file(s) have become corrupted.
    You can use the -tvv option to test integrity of such files.

    You can use the `bzip2recover' program to attempt to recover
    data from undamaged sections of corrupted files.

    tar: Child returned status 2
    tar: /usr/local/apache/htdocs/search22: Not found in archive
    tar: Error exit delayed from previous errors
    [email protected] [/usr/local/apache/htdocs]#

    Doesn't seem to work. Or am I doing it wrong?

  4. #4
    Join Date
    Mar 2004
    Posts
    999
    Even tried to zip it in the same dir, didnt work.

    Code:
    [email protected] [/usr]# tar -jxf /user/local/apache/htdocs/ /user/local/apache/htdocs/search
    tar (child): /user/local/apache/htdocs/: Cannot open: No such file or directory
    tar (child): Error is not recoverable: exiting now
    tar: Child returned status 2
    tar: /user/local/apache/htdocs/search: Not found in archive
    tar: Error exit delayed from previous errors
    [email protected] [/usr]#

  5. #5
    Here is the way I do it

    tar -zcvf somefile.tgz /home/directory/to/zip
    *AlphaOmegaHosting.Com* - Hosting since 1998
    Managed Dedicated Servers and VPS
    Hosted Exchange 2010 Email Service

  6. #6
    Join Date
    Mar 2004
    Posts
    999
    Phew! That worked. Thanks a ton dandadfirema.

    Anything such to bakcup a mysql db?

    Thanks again.

  7. #7
    Join Date
    Mar 2004
    Posts
    999
    Nevermind, figured it:


    mysql -u username -p databasename < filename.sql

    right?

  8. #8
    Join Date
    Oct 2004
    Location
    Southwest UK
    Posts
    1,159
    whooo. NO!

    "mysql -u xxx -p yyy < zzz.sql" means 'IMPORT zzz.sql into the database'. Its what you use to restore from your backups.

    You want <a href="http://dev.mysql.com/doc/mysql/en/mysqldump.html">mysqldump</a>

    mysqldump -u user -p -A > dumpfile.sql


    Also, the original tar command was wrong, -c option means 'create', -x option means 'extract'. Again, that command is how you restore your tar archive. (you'll want -xzvf though, not -jxf).

    (tar options: z = compress it with gzip, j = compress with bzip2, v = verify, f = the filename is xxx. I also use p = restore permissions)

  9. #9
    Join Date
    Mar 2004
    Posts
    999
    Everything worked well. Thanks heaps!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •