Find the answer to your Linux question:
Results 1 to 6 of 6
Good Day. I am need of a small script. I have a dir " /var/lib/mysql " that I need to back up. I want to write a small script to ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    May 2007
    Posts
    33

    Simple Linux Script Help


    Good Day.
    I am need of a small script.
    I have a dir " /var/lib/mysql " that I need to back up.
    I want to write a small script to take the whole directory and put it into an zip file and name the file mysql$datewithhoursandminute.zip. Then I will cron it to write it every night as well as whenever I make major changes I can run it manually.
    Thanks a ton.
    Curtis

  2. #2
    Just Joined!
    Join Date
    May 2007
    Posts
    33
    Bump? - Any links at least?

  3. #3
    Linux Engineer Kieren's Avatar
    Join Date
    Aug 2007
    Location
    England
    Posts
    848
    #!/bin/bash
    file="mysql$(date +%d%m%y%H%M%S).zip"
    zip $file /var/lib/mysql
    Linux User #453176

  4. $spacer_open
    $spacer_close
  5. #4
    Just Joined!
    Join Date
    Feb 2008
    Location
    chennai
    Posts
    24
    hii kieren,

    #!/bin/bash
    file="mysql$(date +%d%m%y%H%M%S).zip"
    zip $file /var/lib/mysql

    could you explain why you gave is line beac i can't understand date +%d%m%y%H%M%S

  6. #5
    Linux Engineer jledhead's Avatar
    Join Date
    Oct 2004
    Location
    North Carolina
    Posts
    1,077
    I assume you are actually trying to backup mysql db and not just a folder called mysql. if thats the case this is the best mysql backup script I have ever used SourceForge.net: AutoMySQLBackup

    you give it usernames and passwords along with what db's to backup. I have it doing nightly backups and rotating 7 days worth, then weekly backups and keeping up to 52 weeks, and then a yearly backup. It does it all itself and knows what day to do what, I just have the same cron job run every night and it does the rest.

  7. #6
    Linux Engineer Kieren's Avatar
    Join Date
    Aug 2007
    Location
    England
    Posts
    848
    Quote Originally Posted by manavalansuresh View Post
    hii kieren,

    #!/bin/bash
    file="mysql$(date +%d%m%y%H%M%S).zip"
    zip $file /var/lib/mysql

    could you explain why you gave is line beac i can't understand date +%d%m%y%H%M%S
    If you type 'date' into your console you will get an output like:

    Thu Feb 21 09:55:32 GMT 2008

    Adding +%d%m%y%H%M%S after date formats the current date as <day of month><month><year><hour><minute><second>. So if you type date +%d%m%y%H%M%S the above date would be output as:

    21022008095532
    Linux User #453176

Posting Permissions

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