Page 1 of 1

cp file.sql.gz to file-02-17.2017.sql.zip

Posted: Fri Feb 17, 2017 8:00 am
by Vegan
I use Ubuntu for want of a distribution for my database, I was wondering if anyone knows how to name a file to the date so that backups can be accumulated over time

Re: cp file.sql.gz to file-02-17.2017.sql.zip

Posted: Fri Feb 17, 2017 8:35 am
by requinix
How are you doing the backups? If there's a shell command involved then you may be able to add a

Code: Select all

`date +'%m-%d-%Y'`
in it to inject the date at that location, eg.

Code: Select all

mysqldump ... > backup-`date +'%m-%d-%Y'`.sql

Re: cp file.sql.gz to file-02-17.2017.sql.zip

Posted: Fri Feb 17, 2017 1:49 pm
by Vegan
By mechanizing backups with a BASH script and cron, then I can go back as needed in case of a disaster

Code: Select all

sudo mysqldump -u root -p --all-databases | gzip > backup-`date +'%m-%d-%Y'`.sql.gz
I am sure anyone reading this post will see the immediate benefit to backup of the backup

Code: Select all

sudo crontab -e
add the script and voila, aged backups, then I can download with FTP and have safe backup in case something gets bricked