From: Eric Frederich <hidden> Date: 2016-06-15 22:49:59
I maintain a corporate MediaWiki installation.
Currently I have a cron job that runs daily and tar's up the contents
of the installation directory and runs a mysqldump.
I keep backups of the past 45 days.
Each backup is about 200M, so all in all I always have about 9.0G of backups.
Most of the changes are in the database, so the mysqldump file is
changed every day.
Other than that, there can be new files uploaded but they never
change, just get added.
All configuration files stay the same.
I wrote a script that untar'd the contents each backup, gunziped the
mysql dump, and made a git commit.
The resulting .git directory wound up being 837M, but after running a
long (8 minute) "git gc" command, it went down to 204M.
== Questions ==
What mysqldump options would be good to use for storage in git?
Right now I'm not passing any parameters to mysqldump and its doing
all inserts for each table on a single huge line.
Would git handle it better if each insert was on its own line?
Lets say that the repo gets too big and I want to throw away history.
I'd have a linear history with a single commit every day.
Is there a way to take just the last 30 commits and throw away everything else?
Am I insane? Are there other tools more suited toward this?
I just thought of using Git since I looked at my 9G worth of data out
there in my backup directory that is almost exactly the same and said
"git could handle this well".
Are any of you using git for a backup system? Have any tips, words of wisdom?
Thanks,
~Eric
From: Jonathan Nieder <hidden> Date: 2016-06-15 22:49:59
Eric Frederich wrote:
Am I insane? Are there other tools more suited toward this?
I just thought of using Git since I looked at my 9G worth of data out
there in my backup directory that is almost exactly the same and said
"git could handle this well".
From: Konstantin Khomoutov <hidden> Date: 2016-06-15 22:49:59
On Mon, 8 Nov 2010 13:01:29 -0500
Eric Frederich [off-list ref] wrote:
I maintain a corporate MediaWiki installation.
Currently I have a cron job that runs daily and tar's up the contents
of the installation directory and runs a mysqldump.
I keep backups of the past 45 days.
Each backup is about 200M, so all in all I always have about 9.0G of
backups. Most of the changes are in the database, so the mysqldump
file is changed every day.
Other than that, there can be new files uploaded but they never
change, just get added.
All configuration files stay the same.
[...]
Am I insane? Are there other tools more suited toward this?
I just thought of using Git since I looked at my 9G worth of data out
there in my backup directory that is almost exactly the same and said
"git could handle this well".
Are any of you using git for a backup system? Have any tips, words
of wisdom?
I suspect the rdiff-backup tool [1] was invented precisely for the setup
like yours: it is able to sync one directory to another + create diffs
between them thus providing for incremental backups.
1. http://www.nongnu.org/rdiff-backup/
I maintain a corporate MediaWiki installation.
Currently I have a cron job that runs daily and tar's up the contents
of the installation directory and runs a mysqldump.
I wrote a script that untar'd the contents each backup, gunziped the
mysql dump, and made a git commit.
The resulting .git directory wound up being 837M, but after running a
long (8 minute) "git gc" command, it went down to 204M.
== Questions ==
What mysqldump options would be good to use for storage in git?
Right now I'm not passing any parameters to mysqldump and its doing
all inserts for each table on a single huge line.
Would git handle it better if each insert was on its own line?
Are any of you using git for a backup system? Have any tips, words of wisdom?
Thanks,
~Eric
Hi Eric,
I also use mysqldump and Git to make backups of my databases. Indeed, it
performs much better when each change (insert statement) is on a
separate line. mysqldump has an option for that which I don't recommend,
because it dramatically slows down the dump and the restore. It would
then create separate "insert into ..." statement for each changed line.
For me the attached script worked very well: I pipe the output of
mysqldump through the script and it simply inserts a linefeed after each
record.
----------------------------------
#!/usr/bin/perl -p
use strict;
use warnings;
# Before:
# INSERT INTO `schliess_grund` VALUES
(1,'Explizit'),(2,'Neuanmeldung'),(4,'Sperrung'),(3,'Timeout');
#
# After:
# INSERT INTO `schliess_grund` VALUES
# (1,'Explizit'),
# (2,'Neuanmeldung'),
# (4,'Sperrung'),
# (3,'Timeout');
if (/^(INSERT INTO .*? VALUES) (.*);$/)
{
$_ = "$1\n $2\n ;\n";
s/\),\(/\)\n ,\(/g;
}
----------------------------------
The changeset will be much smaller. Let's call the script "wrap.pl".
Then run the following:
----------------------------------
mysqldump --opt --routines [...] -r <outfile.tmp> <dbname>
./wrap.pl <outfile.tmp> > <outfile>; rm <outfile.tmp>
git add <outfile>
if ! git diff-index --quiet HEAD --; then
git commit -m "Backup of ..."
fi
----------------------------------
Try it out!
Cheers,
Dirk
On Mon, Nov 8, 2010 at 19:01, Eric Frederich [off-list ref] wrote:
I maintain a corporate MediaWiki installation.
Currently I have a cron job that runs daily and tar's up the contents
of the installation directory and runs a mysqldump.
I keep backups of the past 45 days.
Each backup is about 200M, so all in all I always have about 9.0G of backups.
Most of the changes are in the database, so the mysqldump file is
changed every day.
Other than that, there can be new files uploaded but they never
change, just get added.
All configuration files stay the same.
I wrote a script that untar'd the contents each backup, gunziped the
mysql dump, and made a git commit.
The resulting .git directory wound up being 837M, but after running a
long (8 minute) "git gc" command, it went down to 204M.
== Questions ==
What mysqldump options would be good to use for storage in git?
Right now I'm not passing any parameters to mysqldump and its doing
all inserts for each table on a single huge line.
Would git handle it better if each insert was on its own line?
From: Patrick Rouleau <hidden> Date: 2016-06-15 22:49:59
Eric Frederich <eric.frederich <at> gmail.com> writes:
Are any of you using git for a backup system? Have any tips, words of wisdom?
I had the same idea to backup a MySQL database with git.
To be able to easily drop old "backups", I have choose to go with monthly
branches: each month, the previous month's branch is checked out and a new
branch is created; each year, the previous year is checked out...
This is running only for 5 weeks, but so far it works pretty well.