BackMeUp: An automated MySQL / MariaDB databases and files backup solution on *nix Machines using Amazon S3, WebDAV (ownCloud / NextCloud etc.), Google Drive and Dropbox.
BackMeUp is an automated MySQL databases and files backup solution on Linux Machines using Amazon S3, Dropbox, Mega.nz and WebDAV (NextCloud etc.) as remote storage.
____ _ __ __ _ _
| _ \ | | | \/ | | | | |
| |_) | __ _ ___| | _| \ / | ___| | | |_ __
| _ < / _, |/ __| |/ / |\/| |/ _ \ | | | '_ \
| |_) | (_| | (__| <| | | | __/ |__| | |_) |
|____/ \__,_|\___|_|\_\_| |_|\___|\____/| .__/
| |
|_|
I'm managing my own server, and I wanted to have a simple and easy tool to backup my database and all VirtualHost files, and to save them into a remote server with cronjob.
This script does some simple tasks:
method
is set to dropbox
, The script makes sure that you always have the newest Dropbox-Uploader script.You may easily add this script to your crontab, and just forget about it :smile:
curl
- To download the .backmeuprc file, Dropbox-uploader script and to upload the backup to Dropbox or to WebDAV.mysql
(cli) - To list databases.7z
(cli) - To list compress backup if compression
is set as 7zip, or tar
(cli) if compression
is set as tar
.mysqldump
- To dump databases (in most cases, it comes with mysql
cli).method
is set as s3
.mega-put
command is used that comes with the package) must be installed and configured if the method
is set as mega
.Run these commands first:
curl -s https://raw.githubusercontent.com/Ardakilic/backmeup/master/backmeup.sh -o backmeup.sh
curl -s https://raw.githubusercontent.com/Ardakilic/backmeup/master/.backmeuprc -o ~/.backmeuprc
chmod 600 ~/.backmeuprc
Now, edit the configuration values as stated here.
Make the files secure, executable and only accessible by your root user and group (or the user you'd like the script to run):
chown root:root backmeup.sh #or any user and group who will run the script or with cron
chown root:root ~/.backmeuprc #or any user and group who will run the script manually or with cron
chmod 400 ~/.backmeuprc #Only readable by owner, and is read-only. To make it writable, change to 600 on demand
chmod +x backmeup.sh
(Suggested) Copy or move the script into one of the PATH
s as stated here.
After downloading the script, before running, you must edit your configuration values found in ~/.backmeuprc.
You can set various configuration values on the fly. Here are some full featured examples:
backmeup -tz "Europe/Istanbul" -dbh localhost -dbu root -dbpass "rootpass" -dbp 3306 -f "/usr/share/nginx/html" -b "/tmp" -bf=my_backups -c 7z -7zcp "p4ssw0rd" -m s3 -s3bn my-aws-bucket -wdu "webdav-user" -wdp "webdav-password" -webdav "https://nextcloud-host.com/remote.php/webdav/"
Or like this:
backmeup --timezone="Europe/Istanbul" --database-host="localhost" --database-user="root" --database-password="rootpass" --database-port="3306" --files-root="/usr/share/nginx/html" --base-folder="/tmp" --compression="7z" --7-zip-compression-password="p4ssw0rd" --backup-folder="my-remote-backup-folder" --webdav-user="webdav-user" --webdav-password="webdav-password" --webdav="https://nextcloud-host.com/remote.php/webdav/"
None of these are mandatory, you can just use any of these however you want, and even mix together!
Execute the configured script:
./backmeup.sh #or "backmeup" directly if it's in your PATH.
If this is the first attempt to running and method
is set to dropbox
, Dropbox-Uploader will ask for an APP key and secret. You should create an application, provide these values and click on provided authorization link (Don't worry, the Dropbox-uploader has a nice wizard which guides you, can't be easier). After you've authorized, re-run the script using ./backmeup.sh
If everything went well, in a couple of minutes, you should see your database and files copied into the remote server.
This script saves MySQL password (any user which can show and dump (all) databases will suffice actually) inside, but it's only accessible by its owner and cannot be read by anyone else. In any ways, use it at your own risk. I'm not holding any responsibilities for any damage that this script may do (which shouldn't).
/usr/local/bin/backmeup
and run from there directly. This is suggested
@andreafabrizi for maintaining the Dropbox-Uploader script.
.backmeuprc
and update if necessary.DBHOST
and DBHOST
values should be added in .backmeuprc
~/.backmeuprc
Donations are kindly accepted to help develop my projects further.
BTC: 1QFHeSrhWWVhmneDBkArKvpmPohRjpf7p6
ETH / ERC20 Tokens: 0x3C2b0AC49257300DaB96dF8b49d254Bb696B3458
NEO / Nep5 Tokens: AYbHEah5Y4J6BV8Y9wkWJY7cCyHQameaHc
MIT