0

I'm using ubuntu 16.04 with nginx installed, currently i run daily backup using cron like this:

#crontab -u root -e 0 2 * * * mysqldump -u username -p"password" production | gzip -c > production.gz 

this will backup my database everydate at 2am, the problem here is i need to backup database based on day name, so the backup database name will be suited based on dayname, for example the file name will look like this:

production_monday.gz production_tuesday.gz production_wednesday.gz production_thursday.gz production_friday.gz production_saturday.gz production_sunday.gz 

how can i set the cron to produce the file like above ? cron schedule will auto rewrite the file based on the day name

1
  • 1
    Possible duplicate of Linux shell script for database backup - check that answer and play around with the date formatting options. %A is for the day-of-week. Commented Mar 4, 2019 at 9:04

1 Answer 1

0

My suggestion would be to create a shell script that finds the current day of the week (date +%A), then write the mysqldump output to a file formatted as "prefix"_"dayofweek" for you to zip. Then from cron, just execute this shell script rather than the mysqldump directly.

You may also find this answer helpful.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.