Link to home
Start Free TrialLog in
Avatar of ntrsboy
ntrsboy

asked on

How to create dateandtimestamped and gziped backup script

I have a database called 'database1' in/var/lib/mysq/database1. A want to backup that database every day via cron. Basicly I need a script who will backup my database every day and I would like the file created from the backup to be dateandtimestamped and gziped which means to have a backup files with time stamp such ymd. For examle let say if today is 17/07/2006 is i need the file to be called something like something like db_060717.gz .

Thanks.
Avatar of smidgie82
smidgie82
Flag of United States of America image

Hi ntrsboy,

Create the following script, and add it to your crontab:

#!/bin/bash
mysqldump db_name | gzip -c > /var/lib/mysql/backup/$(date +%y%m%d)


Cheers!
ASKER CERTIFIED SOLUTION
Avatar of smidgie82
smidgie82
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial