Results 1 to 15 of 15
  1. #1

    Talking Is there a linux guru in the house?

    I have the following command...

    mysqldump -uUSERNAME -pPASSWORD DBNAME > /home/blws/DBNAME.sql

    Now the problem is, every time this is run (by cron) it is writing over the old backup. I would like to know if it is possible to put a time stamp or something in the filename.

    So the outcome would be;



  2. #2
    Hope someone can help me

  3. #3
    Join Date
    Jan 2002
    Melbourne, AU
    How about having 7 different cronjobs, one for each day of the week?


  4. #4
    mysqldump -uUSERNAME -pPASSWORD DBNAME > /home/blws/DBNAME.`date +%Y-%m-%d`.sql


  5. #5
    Hmm.. Darin - that for some odd reason isn't working

  6. #6
    Can someone please help?

  7. #7

    What shell are you using to run this command? Which linux distro are you using?

    It will work under bash on most linux systems if the date command is in your path. Remember those `'s have to be the backwards quotes - the ones under the ~ on your keyboard...


  8. #8
    darin - it is a CPANEL run server with red hat 7.2

  9. #9
    and as for shell.. it is being run thru cron

  10. #10
    Somethings amiss then - here is the about of echoing that command on a Redhat 7.2 box

    [darin] $ cat /etc/issue

    Red Hat Linux release 7.2 (Enigma)
    Kernel 2.xx.xxxx on an i686

    [darin] $ echo "mysqldump -uUSERNAME -pPASSWORD DBNAME > /home/blws/DBNAME.`date +%Y-%m-%d`.sql "
    mysqldump -uUSERNAME -pPASSWORD DBNAME > /home/blws/DBNAME.2002-08-02.sql

    If it's being run via cron, the shell is /bin/sh which on most boxes is /bin/bash which will run that command.

    [COLOR=royal blue]Deru[/COLOR] Communications

  11. #11
    trying it through cpanel now...

  12. #12
    the errors I recieve are..

    /bin/sh: -c: line 1: unexpected EOF while looking for matching ``'
    /bin/sh: -c: line 2: syntax error: unexpected end of file

    That is when I do it thru cpanel cron

  13. #13
    Wonder why it wont work thru cron but will thru SH.. ffs

  14. #14
    ok - use this:

    mysqldump -uUSERNAME -pPASSWORD DBNAME > /home/blws/DBNAME.`date +\%Y-\%m-\%d`.sql
    [COLOR=royal blue]Deru[/COLOR] Communications

  15. #15
    Join Date
    May 2002
    mysqldump -uUSERNAME -pPASSWORD DBNAME > /home/blws/DBNAME.`date '+%Y-%m-%d'`.sql

    (remember normal quotes around the +%Y-%m-%d)
    Clook Internet -
    Fully managed UK based webhosting provider
    Est 2002, 24/7 phone support, all the bells and whistles!

Posting Permissions

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