MySQL Plugin Feature Request

    • OMV 2.x
    • MySQL Plugin Feature Request

      Hello everyone,
      I'm running a personal Wordpress site on my NAS using MySQL plugin to store the database. The plugin is good since it allows you to auto-backup the database into a defined shared folder whenever you want creating a cron-job.
      My question is if it would be very difficult to implement a feature which would let the user to delete old SQL dumps from the shared folder. Like in the RSnapshot plugin where you can select how many daily, weekly, monthly... backups do you want to keep.

      If it can not be implemented in the plugin, is there any way to do a cron-job or something to delete SQL dumps older than X days?


      Thank you!
      Guillem
      DISCLAIMER: :!: I'm not a native English speaker, I'm sorry if I don't explain as good as you would want. :!:

      My NAS:
      Always the latest OMV Erasmus running on an AMD Sempron 3850 @1.3GHz with 4.9.0 Backports Kernel
      with 120GB Samsung SSD 850 EVO for OpenMediaVault & 2x500GB Primary Data HDD + 1TB Secondary HDD for Backup & 2TB USB 3.0 External HDD for offline backup

      Plugin list:
      Flash Memory, Locate, OMV-Extras.org, RSnapshot, Sensors, Syncthing, SMB/CIFS, SSH, USB Backup
      _____________________________________________________________________________________________________________________________

      The Schrödinger's code is that one which is going to work and it's full of bugs at the same time; until you test it, you won't be able to determine it.
    • I use a script to dump, compress and delete old sql dumps.

      Shell-Script

      1. #!/bin/bash
      2. user="root"
      3. password="geheim"
      4. db2="alldump"
      5. backup_path="/media/983cbc4d-f06f-465b-a931-525b26a21dd7/backup/server#1/mysql"
      6. date=$(date +"%d-%b-%Y")
      7. echo "Backing up mysql databases..."
      8. if [ -f "$backup_path/$db2-$date.sql.lz4" ]; then
      9. rm -fv $backup_path/$db2-$date.sql*
      10. fi
      11. echo "Dumping databases..."
      12. mysqldump --single-transaction --skip-lock-tables --user=$user --password=$password --all-databases > $backup_path/$db2-$date.sql
      13. echo "Compressing databases..."
      14. lz4 $backup_path/$db2-$date.sql > $backup_path/$db2-$date.sql.lz4
      15. chmod 600 $backup_path/$db2-$date.sql.lz4
      16. # Delete lz4 files older than 60 days and Delete sql files older than 30 days
      17. echo "Checking for old files..."
      18. find $backup_path/* -type f -mtime +60 -name 'alldump*' | head -n -5 | xargs rm {} \;
      19. find $backup_path/* -type f -mtime +30 -name 'alldump*.sql' | head -n -5 | xargs rm {} \;
      20. echo "Done."
      Display All
      You can try that line whit Scheduled jobs, that example will delete sql dumps older then 30 days but keeps a minimum of 5 dumps.

      find /backup_path -type f -mtime +30 -name '*.sql' | head -n -5 | xargs rm {} \;

      but use it whit care, wrong path or filename wildcard and rm flush the wrong files
    • Thanks for that script @LooR. Since I'm a bit novice in Linux and scripting commands, I'll save the script but I'll not use it until I'm a bit more experienced; just in case I broke something and I delete all the root directory ;(

      Thanks again to share it with us.

      Guillem
      DISCLAIMER: :!: I'm not a native English speaker, I'm sorry if I don't explain as good as you would want. :!:

      My NAS:
      Always the latest OMV Erasmus running on an AMD Sempron 3850 @1.3GHz with 4.9.0 Backports Kernel
      with 120GB Samsung SSD 850 EVO for OpenMediaVault & 2x500GB Primary Data HDD + 1TB Secondary HDD for Backup & 2TB USB 3.0 External HDD for offline backup

      Plugin list:
      Flash Memory, Locate, OMV-Extras.org, RSnapshot, Sensors, Syncthing, SMB/CIFS, SSH, USB Backup
      _____________________________________________________________________________________________________________________________

      The Schrödinger's code is that one which is going to work and it's full of bugs at the same time; until you test it, you won't be able to determine it.
    • Finally I tested this with a testing database but I got these errors:


      Source Code

      1. root@OMV:~# find /media/8ed09fff-96f5-4b07-ac70-4aa015cb2a0c/Guillem/WordpressBackup/DB -type f -mtime +30 -name '*.sql' | head -n -5 | xargs rm {} \;
      2. rm: no s’ha pogut eliminar «{}»: El fitxer o directori no existeix
      3. rm: no s’ha pogut eliminar «;»: El fitxer o directori no existeix



      It says that it could not delete {}: File or directory not found.
      Same for ;

      Did I miss something or you made a typo?


      Thanks.
      DISCLAIMER: :!: I'm not a native English speaker, I'm sorry if I don't explain as good as you would want. :!:

      My NAS:
      Always the latest OMV Erasmus running on an AMD Sempron 3850 @1.3GHz with 4.9.0 Backports Kernel
      with 120GB Samsung SSD 850 EVO for OpenMediaVault & 2x500GB Primary Data HDD + 1TB Secondary HDD for Backup & 2TB USB 3.0 External HDD for offline backup

      Plugin list:
      Flash Memory, Locate, OMV-Extras.org, RSnapshot, Sensors, Syncthing, SMB/CIFS, SSH, USB Backup
      _____________________________________________________________________________________________________________________________

      The Schrödinger's code is that one which is going to work and it's full of bugs at the same time; until you test it, you won't be able to determine it.