?
Solved

How to create dateandtimestamped and gziped backup script

Posted on 2006-07-10
2
Medium Priority
?
208 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 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
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…
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.
Suggested Courses
Course of the Month11 days, 9 hours left to enroll

752 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