Advertisement

09.26.2008 at 09:53AM PDT, ID: 23766697
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.0

MySQL backup script using mysqlhotcopy / gzip / incremental backups

Asked by cmercado_miranda in MySQL Server, Backup Exec, Bourne-Again Shell (bash)

Tags: , ,

Hello,

Currently I have this shell script to backup my databases using mysqlhotcopy and saving 4 previous copies of the backup. The script is working fine and it does the work well. The Only thing I need to add is that instead of creating just the folder of the backup db, it also compress those created folders in a separate gzip files, so that way I can send it via FTP to another serve more easily than transferring all the db file contents.

So basically is change this script to instead of creating the folders like this:
testdb.1
testdb.2
testdb.3
testdb.4

it creates something like
testdb.1.tar.gz
testdb.2.tar.gz
testdb.3.tar.gz
testdb.4.tar.gz

and so on....

That's basically it...

Attached is the code...

Thanks
Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
#!/bin/sh
 
# List of databases to be backed up separated by space
dblist="testdb testdb2 testdb3"
 
# Directory for backups
backupdir=/home/mysql/backup
 
# Number of versions to keep
numversions=4
 
# Full path for MySQL hotcopy command
hotcopycmd=/usr/bin/mysqlhotcopy
 
# MySQL Username and password
userpassword=" --user=root --password=password"
 
# Create directory if needed
mkdir -p ${backupdir}
if [ ! -d ${backupdir} ] 
then
	echo "Invalid directory: ${backupdir}"
exit 1
fi
 
# Hotcopy begins here
echo "Hotcopying MySQL Databases..."
RC=0
for database in $dblist
do
	echo "Hotcopying $database ..."
	$hotcopycmd $userpassword $database ${backupdir}
	RC=$?
	if [ $RC -gt 0 ]
	then
		break;
	fi
 
	# Rollover the backup directories
	i=$numversions
	mv ${backupdir}/${database} ${backupdir}/${database}.0 2> /dev/null
	rm -fr ${backupdir}/${database}.$i 2> /dev/null
	while [ $i -gt 0 ]
	do
		 mv ${backupdir}/${database}.`expr $i - 1` ${backupdir}/${database}.$i 2> /dev/null
		 i=`expr $i - 1`
	done
done
 
if [ $RC -gt 0 ]
then
	echo "MySQL Hotcopy failed!"
	exit $RC 
else
	# Hotcopy is complete. List the backup versions!
	ls -l ${backupdir}
	echo "MySQL Hotcopy is complete!"
fi
exit 0
 
Keywords: MySQL backup script using mysqlhotc…
 
Loading Advertisement...
 
[+][-]09.26.2008 at 12:49PM PDT, ID: 22583083

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: MySQL Server, Backup Exec, Bourne-Again Shell (bash)
Tags: MySQL, MySQL Server, Database backups using mysqlhotcopy
Sign Up Now!
Solution Provided By: MikeOM_DBA
Participating Experts: 1
Solution Grade: A
 
 
[+][-]09.26.2008 at 01:06PM PDT, ID: 22583234

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.01.2008 at 01:34PM PDT, ID: 22858730

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]11.07.2008 at 07:15PM PST, ID: 22910595

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628