Solved

How to create dateandtimestamped and gziped backup script

Posted on 2006-07-10
2
207 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Using 'screen' for session sharing, The Simple Edition Step 1: user starts session with command: screen Step 2: other user (logged in with same user account) connects with command: screen -x Done. Both users are connected to the same CLI sessio…
SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

728 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