Help - Search - Members - Calendar
Full Version: Compress & Copy Folder Script
The Planet Forums > System Administration > General Support Questions
bamaster
Hello,

I'm looking for a way to GZip compress a MySQL folder (with the MYD and MYI files), assign it a specific name with the date in it, then copy/move that file into a specific folder.

The MySQL path is
/var/lib/mysql/[database name]

and the destination path is
/home/httpd/vhosts/[domain]/dbbackup

Thank in advance!
jaume
create a shell script with this:

CODE
#!/bin/sh



DAY=`date +%d%m%Y`



mkdir /home/httpd/vhosts/[domain]/$DAY



tar czvf /home/httpd/vhosts/[domain]/$DAY/dbbackup.tar.gz /var/lib/mysql/[databasename]



exit 0


Substitute [domain] and [databasename] , chmod script to executable and execute.
bamaster
Excellent reply. Worked 100%!

There ought to be a Shell Script Power Pack that chumps like me could install and be good to go.

Thanks again for your time posting.
RexAdmin
Backing up MySQL files on live server with that method is highly unrecommended.

You should make MySQL Dump and than automatically gzip (bzip2) it and move to safe place.

Best luck.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.