Solved

How to create dateandtimestamped and gziped backup script

Posted on 2006-07-10
2
202 Views
Last Modified: 2013-12-16
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.
0
Comment
Question by:ntrsboy
  • 2
2 Comments
 
LVL 9

Expert Comment

by:smidgie82
ID: 17074749
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!
0
 
LVL 9

Accepted Solution

by:
smidgie82 earned 500 total points
ID: 17074757
Oops, should probably tack a .gz on the end of that filename:

mysqldump db_name | gzip -c > /var/lib/mysql/backup/$(date +%y%m%d).gz
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

The purpose of this article is to demonstrate how we can use conditional statements using Python.
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now