How to Add Date and Time Into Database Backup File Name in mysqldump

By | February 24, 2016

If you ever made backups from command line, you’d probably wanted to do this on a regular basis, including date and time of your backup (e.g. to keep backups for a week or so). Here is a simple command, that will allow you to do this:

mysqldump -h host -u user -p password database_name > backup_$(date "+%b-%d-%Y-%H-%M-%S").sql

You can specify your own format by adding or removing date parameters. This command will give you something like Feb-24-2016-12-12-13.

20 thoughts on “How to Add Date and Time Into Database Backup File Name in mysqldump

  1. aravinth nageswaran

    For 2020 use below code

    set TIMESTAMP=%DATE:~6,4%%DATE:~3,2%%DATE:~0,2%%
    echo %TIMESTAMP%
    pause

    Reply
  2. www.Waste-Ndc.pro

    Greetings I am so happy I found your site, I really found you by
    accident, while I was looking on Google for something else, Nonetheless I am here
    now annd would just like to say kudos for a marvelous post and
    a all round thrilling blog (I also love tthe theme/design), I don’t have time to
    read through it all att the minute but I hav bookmarked it and
    also included your RSS feeds, soo when I have time I will
    be back to readd much more, Please do keep up the fantastic job. https://www.waste-ndc.pro/community/profile/tressa79906983/

    Reply
  3. 663ce61154D61.site123.me

    Awesome blog! Do yoou have any tips for aspiring writers?
    I’m planning to start my own site soon but I’m a little lost on everything.
    Would you suggest starting with a free platform like WordPress or
    go for a paid option? There are so many options out there that I’m
    completely overwhelmed .. Any ideas? Thanks! https://663ce61154d61.site123.me/

    Reply
  4. https://gamesoffers9.wordpress.com/

    Magnificxent goods fom you, man. I’ve understand your stuff previous to and you are just too wonderful.

    I actually like what you have acquired here, certainly like what you’re
    stating and the way in which youu say it. You make it enjoyable and you still take care of to keep it sensible.
    I cant wait to rea much more from you. This is really a tremendous
    website. https://gamesoffers9.wordpress.com/

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *