Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backup failing due to database being in use #11822

Open
rickgardner077 opened this issue Aug 6, 2022 · 3 comments
Open

Backup failing due to database being in use #11822

rickgardner077 opened this issue Aug 6, 2022 · 3 comments

Comments

@rickgardner077
Copy link

rickgardner077 commented Aug 6, 2022

I have a single user Friendica instance on a shared host. Every night a backup is started but fails due to the database being in use.

Aug 04 03:50:54 vega.uberspace.de uberspace-dump-sqldbs[31762]: mysqldump: Error 1412: Table definition has changed, please retry transaction when dumping table `process` at row: 0

Aug 04 03:50:54 vega.uberspace.de uberspace-dump-sqldbs[31762]: failed to dump 'rick6_friendica' (0)`

Is there a way to lock the database prior to backing up? Thanks

@AlfredSK
Copy link

AlfredSK commented Aug 6, 2022

I enable the maintenance mode when the backup is running. Like this...

cd /path/to/friendica
sudo -u www-data php bin/console.php maintenance 1 "Database full backup is running. Maintenance mode enabled."
sleep 120
mysqldump --quick --single-transaction -h localhost -u dbuser dbname > /path/to/backup/friendica/friendicadb_`date +"%Y%m%d"`.sql
cd /path/to/friendica
sudo -u www-data php bin/console.php maintenance 0

@annando
Copy link
Collaborator

annando commented Aug 8, 2022

Some smaller tables with a lot of inserts and deletes (like the cache or session table) are regularly optimized. This seem to confuse your backup command.

@SpcCw
Copy link

SpcCw commented Aug 11, 2022

I also use maintenance mode before backups.

If for some reason you don't want to (but try it - it really works nice) then you can just setup your backup script to retry on error until success, somehow like this:

for i in {1..40}
do
   echo "Attempt $i..."
   /usr/sbin/backup-manager
   if [ $? -eq 0 ]
      then
          echo "Succesful backup on $i attempt at $(date)"
          break
   fi
   sleep 120
done

I used to have this and it managed to do backups but sometimes took as much as 10-20 attempts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants