Skip to content

Instantly share code, notes, and snippets.

@philipp-r
Last active June 23, 2023 07:22
Show Gist options
  • Save philipp-r/59506a2c8a7b38e98408a121ab8b2e4a to your computer and use it in GitHub Desktop.
Save philipp-r/59506a2c8a7b38e98408a121ab8b2e4a to your computer and use it in GitHub Desktop.
Backup MySQL database with MEGAcmd https://github.com/meganz/MEGAcmd/
#!/bin/bash
DATE=`date +%Y-%m-%d-%H-%M`
# PATH
PATH=/bin:/usr/bin:/usr/local/bin
# mysql dump
mysqldump -u nextcloud_backup -pPASSWORD --databases nextcloud > mysql_$DATE.sql
wait
# zip
7z a -mhe=on -pPASSWORD mysql_$DATE.7z mysql_$DATE.sql
wait
# backup with mega.nz
mega-put mysql_$DATE.7z /
wait
# delete the oldest backup from mega
mega-rm -rf `mega-ls / | awk 'NR<2'`
# delete dumped file
rm -f mysql_$DATE.sql
rm -f mysql_$DATE.7z
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment