Results 1 to 4 of 4

Thread: MySQL not liking my sloppy tarring...

  1. #1
    Join Date
    Feb 2008
    Location
    Hamilton, Canada
    Beans
    Hidden!

    MySQL not liking my sloppy tarring...

    In backing up my server, I back up my databases with mysqldump. I save that file in /tmp, tar it (w/ gzip), and move it to the backup storage.

    However, while phpmyadmin handles .tar.gz, it doesn't like my file, since the .sql file isn't in the root directory of the archive.

    That is... when I run tar, it saves the entire directory structure leading up to the file... which is what it's supposed to do.

    If I want to import my database back, I need to untar it first, which I don't mind, but I was wondering if there was a way around having to do so...

    There has to be, since precompiled software untars right to the current directory...!

  2. #2
    Join Date
    May 2007
    Location
    Leeds, UK
    Beans
    1,664
    Distro
    Ubuntu 13.10 Saucy Salamander

    Re: MySQL not liking my sloppy tarring...

    There's an option you can pass to tar to get it to change to a directory for the context of the archive:

    Code:
    -C, --directory DIR
               change to directory DIR
    See manual page for tar.

    So, I believe something like this would leave the .sql file in the root:

    $ tar -C /tmp -czf myArchive.tar.gz myFile.sql

  3. #3
    Join Date
    Feb 2008
    Location
    Hamilton, Canada
    Beans
    Hidden!

    Re: MySQL not liking my sloppy tarring...

    Perfect... I knew about -C, but I had no clue where to use it, since anywhere I put it, it didn't do diddly-squat...

    Before "czf"... I see...

  4. #4
    Join Date
    Jul 2009
    Location
    London
    Beans
    1,480
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: MySQL not liking my sloppy tarring...

    or you could have just cd'ed to the /tmp directory before running your tar command, in which case the tar archives files would be relative to that directory
    Code:
    $ cd /tmp
    $ tar czf somefile.tgz somefile
    $ tar tzf somefile.tgz
    somefile

Tags for this Thread

Bookmarks

Posting Permissions

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