Page 1 of 1


Posted: 01 Jul 2013, 13:40
by lyda
This isn't really a post asking a question. I'm describing how I'm doing backups here with the following two hopes:

1) Seeing if people have suggestions for additional things I should do or if I missed anything.
2) Helping people looking to script backups.

From what I can tell, all I need to backup is the database. Note that my deployment scripts and config files are in version control (where they belong). So to back up the database I have the following two files:


Code: Select all

50 4 * * * root /usr/local/sbin/ expire

cat usr/local/sbin/

Code: Select all


TS=$(date +"%Y-%m-%d_%H:%M:%S")

if [[ ! -d "$BACKUP_DIR" ]]; then
  mkdir -p "$BACKUP_DIR"

mysqldump --single-transaction ttrss > "$BACKUP_DIR/,$BACKUP_STEM"

if [[ "$1" == "expire" ]]; then
  find /backups -mtime +7 -print0 | xargs -0 rm -f

I find this compresses very well and doesn't put a lot of load on the system. It keeps the last 7 days of backups just in case there's an issue with a rollback. Traditionally on Unix systems a file that begins with a , is a temporary file and the command I use to rsync files excludes such files - which is why the backup file starts with a , until it's done.

For DB auth, I have a /root/.my.cnf file with the auth credentials I need.

Re: Backups

Posted: 01 Jul 2013, 15:12
by fox
Should've posted to KB. :)

Re: Backups

Posted: 01 Jul 2013, 15:22
by sleeper_service
fox wrote:Should've posted to KB. :)

well, that was my bad, it was originally in support, where it didn't belong.

Re: Backups

Posted: 01 Jul 2013, 16:54
by ajs124
You could always pipe to lzip/xz/whatever instead of writing it to an uncompressed file and compressing it later. But besides that I didn't know about the "--single-transaction" parameter, which seems like a good idea to use.

Re: Backups

Posted: 01 Jul 2013, 19:58
by lyda
Re: forum movement

My apologies for the wrong location. I wasn't satisfied it was complete so I didn't feel it rated "knowledge base" yet. :)

Re: mysqldump -> file; lzip file.

I mainly did this to limit how long mysqldump was running. It shouldn't lock anything, but it does put some amount of pressure on the DB to store state for transaction. And since I want to nice the lzip command (which is slow enough already) I figured splitting the job would work better.

If you're not too concerned about cpu spikes, you could do this instead (and remove the lzip line):

mysqldump --single-transaction ttrss | lzip > "$BACKUP_DIR/,$BACKUP_STEM.lz"

Regarding compression tools, I didn't try xz. I tried gzip, bzip2 and lzip - lzip was 2/3 the size of gzip and I decided to leave it there. xz and 7zip could probably do incrementally better; I haven't seen the ratings recently. Plus sql / feed backups might have certain characteristics that make them compress insanely better so definitely an area one could experiment with.

As an aside, my hosting is a macmini running Ubuntu. I suspect the ideal system for tt-rss would have at least two spindles (one for the OS and one for mysql) with a second machine for a mysql replica (or a postgres replica if you're using postgres). But It seems to function fine with just a single disk.

I've set it up using LXC with one container for ttrss and one for mysql. I can write that up if people are interested.

Re: Backups

Posted: 01 Jul 2013, 21:00
by gbcox
I'm using postgresql now but information on mysql/mariadb backups can be found here: ... edora.html

Another related post is here: ... y-rss.html

Re: Backups

Posted: 01 Jul 2013, 23:38
by lyda
gbcox: Very cool. I don't run Fedora or use postgres, but good stuff to look through.