standbymeintothewild

Members
  • Posts

    1
  • Joined

  • Last visited

Everything posted by standbymeintothewild

  1. Hi, I have not seen anyone else show how to use mysqldump to generate database backups similar to https://docs.nextcloud.com/server/latest/admin_manual/maintenance/backup.html So this is the script I smashed together to make my backups (using user script) Recap what is does The script sets nextcloud in maintenance mode first Then the backup run (note that I use the utf8mb4 setting) | I compress it a bit (this could be better) and add a timestamp to the file. There is printed a successful or not statement to the terminal/log Nextcloud is taken out of maintenance Then I keep the 7 newest files and delete any older ones in my case keep the last 7 days. (this is due to not bloat my remote backup) It produces an error message here but it works. The dedicated backup user have these privileges “SELECT, SHOW VIEW, TRIGGER, PROCESS, LOCK TABLES” for the db. I can’t remember where I found the overview of what was necessary. You could use the root user, just don’t, that user is too valuable. I hope this is helpful and do you have any feedback let me know. #!/bin/bash #description=Run to backup db for nextcloud #foregroundOnly=false #backgroundOnly=false #arrayStarted=true #turn on maintenacemode docker exec nextcloud occ maintenance:mode --on #Backup and compression of db docker exec MariaDB /usr/bin/mysqldump --single-transaction --default-character-set=utf8mb4 --user={{Dedicated Backup user}} --password={{password}} nextcloud | gzip > /mnt/user/{{full path to backup}}/nextcloudDB/nextcloud-sqlbkp_`date +"%Y%m%d"`.gz if [ "$?" -eq 0 ] then echo "Mysqldump executed successfully" else echo "Mysqldump encountered a problem" fi #turn off maintenacemode docker exec nextcloud occ maintenance:mode --off #Keep the 7 newest files, delete the oldest cd /mnt/user/{{full path to backup}}/nextcloudDB && ls -tp | grep -v '/$' | tail -n +8 | tr '\n' '\0' | xargs -0 rm --