Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
To add to what Habitual said, you should then copy the backup to another machine or drive (In case the drive fails). Depending on how sensitive and valuable the data is in the database, you might want to back it up off site as well (In case the building catches fire).
You could also consider MySQL replication as well as regular rsync of your website files.
One of the three backup methods / locations that I use for a large forum does this kind of replication and rsync to a Raspberry Pi with a 32Gb SD card that sits beside a network switch at home, not quite "free", but not bad for under $100 for the hardware
If you're interested I'll post the script I use on my production website that can be set to stop MySQL replication, takes a dump with the day name, and rsyncs the backup to an offserver location.
(Oh, and as I'm REALLY, REALLY paranoid about data loss I have my replication slave take an HOURLY backup dump of databases just incase a DROP statement gets replicated!)
Do any of you have any ideas on how I could get the .tar.gz MySQL backups to automatically sync to my personal laptop? Would I use rsync? (I figure my laptop, although not a perfect solution, is *free* storage and at least works as a backup)
TenTenths I would love for you to post that script if you have time!
FYI, I ended up using automysqlbackup on the Linux server, which creates daily and weekly backups of all MySQL databases, and then using the following batch file on my laptop and scheduling it to run daily in Windows Task Scheduler to copy the MySQL database backup folder from the server to my laptop. It'll keep 1 weeks worth (7 copies) of the folder that I'm syncing.
Code:
@echo off
REM Keeps 1 week worth of database backups from server
REM Which day of the week is it?
SETLOCAL enabledelayedexpansion
SET /a count=0
FOR /F "skip=1" %%D IN ('wmic path win32_localtime get dayofweek') DO (
if "!count!" GTR "0" GOTO next
if %%D == 1 set dow=Monday
if %%D == 2 set dow=Tuesday
if %%D == 3 set dow=Wednesday
if %%D == 4 set dow=Thursday
if %%D == 5 set dow=Friday
if %%D == 6 set dow=Saturday
if %%D == 7 set dow=Sunday
SET /a count+=1
)
:next
REM Delete backup from last week
FOR /D %%f in (*%dow%*) DO (
rmdir %%f
)
REM Create directory with today's date and current time
set datetime=%dow%_%date:~-10,2%.%date:~-7,2%.%date:~-4,4%_%time:~0,2%.%time:~3,2%
md "C:\Users\me\Desktop\database_backups\backup_%datetime%"
REM Copy database backups directory to laptop
cd "C:\Users\me\Desktop"
pscp -r -batch -pw mypassword me@999.999.999.999:/backups/* C:\Users\me\Desktop\database_backups\backup_%datetime%
Percona offers a lot in the mysql arena. I've had a couple projects completely leave mysql and switch to percona after seeing the xtrabackup and replication.
Last edited by szboardstretcher; 06-06-2014 at 02:23 PM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.