0

I use incron to create backups for a website, and I like to redirect all requests to an other site when/while my scripts are running.

What I have done so far...
incron runs some scripts every time I update files in /var/www. First it adds some entries to a database. Then it makes an gnu incremental backup with tar. After that it uses mysqldump for extraction of the database and gzip for compression the sql file.

Now I like to add statistics to my database too. I was thinking of adding /var/log/apache2/access.log to incron.

But this way I can mess up my database backups. I need a save way to extract my database without shutting down apache nor mysql. I could block write access on mysql but my website will still be available and I cant update statistics in the mean time without getting an error.

Is there a way to redirect all access of one domain, as long my scripts are running ? Maybe mod_rewrite with some if, but which arguments I have to use then ?

to be hornest, I have no clue how to archive this and I will be pleased to hear some advice.

Apache 2.4.10
MySQL 5.7
Debian Jessie

Mario
  • 115
  • 4

1 Answers1

0

I need a save way to extract my database without shutting down Apache nor MySQL.

I think you just want to avoid any modifications to your database during the backup, in order to keep it consistent. You might be just over-complicating this with your redirecting scenario, if everything is on a single database. MySQL 5.7 Reference Manual for mysqldump helps us here:

--lock-tables, -l

For each dumped database, lock all tables to be dumped before dumping them. The tables are locked with READ LOCAL to permit concurrent inserts in the case of MyISAM tables. For transactional tables such as InnoDB, --single-transaction is a much better option than --lock-tables because it does not need to lock the tables at all.

Because --lock-tables locks tables for each database separately, this option does not guarantee that the tables in the dump file are logically consistent between databases. Tables in different databases may be dumped in completely different states.

--single-transaction

This option sets the transaction isolation mode to REPEATABLE READ and sends a START TRANSACTION SQL statement to the server before dumping data. It is useful only with transactional tables such as InnoDB, because then it dumps the consistent state of the database at the time when START TRANSACTION was issued without blocking any applications.

When using this option, you should keep in mind that only InnoDB tables are dumped in a consistent state. For example, any MyISAM or MEMORY tables dumped while using this option may still change state.

Esa Jokinen
  • 43,252
  • 2
  • 75
  • 122