I am exploring possibilities to minimize the size of the database dump (for backing up the WordPress content automatically) of several WordPress instances.
What I am wondering about most of all is if there is any generated data stored in the database which I can safely discard during backups because it will be re-generated by WordPress (or some action that can be manually performed after a backup). For example for phpBB3 it's usually safe to discard search terms and such, because you can easily re-index after disaster recovery ...
Oh, I should probably add that I've read this and didn't deduce any method to minimize dump size from that (aside from --compact
and --skip-comments
command line switches to mysqldump
).
I investigated a little further on my own. Previously I had tried Git and Mercurial to store pretty much only the difference between two snapshots, but these tools aren't very good for that particular purpose. I also tried rdiff-backup
, but the results were ... uhm, mediocre.
Anyway, I think I may have found an alternative to shrinking the individual (DB) snapshot size. I have experimented with repackaging the SQL dump files. Numbers:
- 24 hours worth of (hourly) backups amount to ~1500 MiB for one of the blogs I use this for.
- Individually compressed (
gzip -9
) these clock in at ~540 MiB altogether (per 24 hour period)
- Individually compressed (
- Repackaging the 24 hours worth of backup into a single archive with
xz
I came up with the following numbers:xz -6
: still > 300 MiBxz -7
: still > 300 MiBxz -9
: depending on the day somewhere between 10 and 30 MiB ... I found the variance surprising, but it may be due to the spam comments, so this needs more experimenting.
Anyway for now - and unless there are some further answers providing more insight it will remain that way - I am going with:
- repackaging my backups from the last 24 hour period
- adding the latest files from that last 24 hour period
And I will see whether this scales for me for monthly backups as well or whether I need to thin out the backups prior to repackaging.
On the DB dump shrinking front the --where
command line switch to mysqldump
seemed promising, but I have yet to be able to express where comment_approved not in ('spam', 'trash')
in a way that works on all the tables in the blog-specific database, which makes it kinda impractical to use:
mysqldump: Couldn't execute 'SELECT /*!40001 SQL_NO_CACHE */ * FROM `wp_commentmeta` WHERE comment_approved not in ('spam', 'trash');': Unknown column 'comment_approved' in 'where clause' (1054)
(referring to the column name like wp_comments.comment_approved
doesn't help either)