GithubHelp home page GithubHelp logo

ardakilic / backmeup Goto Github PK

View Code? Open in Web Editor NEW
82.0 9.0 13.0 47 KB

BackMeUp: An automated MySQL / MariaDB databases and files backup solution on *nix Machines using Amazon S3, WebDAV (ownCloud / NextCloud etc.), Google Drive and Dropbox.

License: MIT License

Shell 100.00%
shell database owncloud backup-files dropbox mysql-backup aws-s3 google-drive rclone webdav

backmeup's Introduction

BackMeUp

⚠️This repository is deprecated. Use proper tools such as rclone, docker backup scripts etc. Hence the repository is now read-only as of 2024.05.16 ⚠️

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.

  ____             _    __  __      _    _       
 |  _ \           | |  |  \/  |    | |  | |      
 | |_) | __ _  ___| | _| \  / | ___| |  | |_ __  
 |  _ < / _, |/ __| |/ / |\/| |/ _ \ |  | | '_ \ 
 | |_) | (_| | (__|   <| |  | |  __/ |__| | |_) |
 |____/ \__,_|\___|_|\_\_|  |_|\___|\____/| .__/ 
                                          | |    
                                          |_|    

Why?

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.

What This Script Does

This script does some simple tasks:

  • The script dumps all of your MySQL databases individually.
  • The script backs up all of your Web files (e.g: root path of all of your virtual hosts).
  • The script compresses your web-root and databases to a single archive.
  • The script uploads the compressed archive into a folder in your Dropbox account, Amazon S3 bucket, Mega.nz or to a WebDav solution such as OrnCloud/NextCloud Server.
  • If the method is set to dropbox, The script makes sure that you always have the newest Dropbox-Uploader script.
  • After the upload, the script cleans up the temporary files (dumps, the archive itself).

You may easily add this script to your crontab, and just forget about it 😄

Requirements

  • 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).
  • aws-cli must be installed and configured if the method is set as s3.
  • mega-cmd (the mega-put command is used that comes with the package) must be installed and configured if the method is set as mega.

Installation

  • 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 PATHs as stated here.

Configuration Values

After downloading the script, before running, you must edit your configuration values found in ~/.backmeuprc.

On-the-fly Configuration

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!

Usage

  • 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.

Important Notice

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).

Additional Notes

  • You can also copy the script to one of your PATHS, such as /usr/local/bin/backmeup and run from there directly. This is suggested

Screenshots

Special Thanks

@andreafabrizi for maintaining the Dropbox-Uploader script.

TODOs

  • Tests on CentOS, Arch etc.
  • WebDAV (Owncloud etc.) Integration
  • AWS S3 integration
  • Increased security? (backup is encrypted with a password now for 7zip archives)
  • Reading configuration from an external file
  • Postgres support
  • Option to dump only the database(s) or only Virtualhost files
  • Multiple Virtualhost folder support

Version History

1.5.0

  • Google drive feature implemented
  • A minor fix on creating folders step

1.4.0

  • Mega.nz integration implemented

1.3.0

  • 7-zip archive support
  • Encryption support for 7-zip archives.

1.2.0

  • WebDAV (Owncloud etc.) Integration: You can now upload your backup files to your WebDAV server using WebDAV bridge and curl. You can refer to updated .backmeuprc and update if necessary.

1.1.0

  • You can now define "Database Host" and "Database Port" parameters, so you may even get dumps from remote services such as Amazon RDS. DBHOST and DBHOST values should be added in .backmeuprc
  • The version numbers will follow Semantic Versioning from now on.

1.0.1

  • External configuration file support. Now you can update backmeup hassle-free! The file's located at: ~/.backmeuprc
  • Amazon S3 Storage Class Support: Now you can set how the backup will be stored (Normal or Infrequent Access or Reduced Redundancy for lesser storage costs).
  • An issue with Dropbox-uploader download path is fixed.

1.0.0

  • Amazon S3 support (using official aws-cli)
  • The code is optimised to use in cron
  • Arguments and options support. You can pass the arguments and options to the script on-the-fly

0.1.1

  • Defined PATHs to the script so that it should work better on cron withot needing to define before running.

0.1.0

  • Initial Release

Buy me a coffee or beer!

Donations are kindly accepted to help develop my projects further.

BTC: 1QFHeSrhWWVhmneDBkArKvpmPohRjpf7p6

ETH / ERC20 Tokens: 0x3C2b0AC49257300DaB96dF8b49d254Bb696B3458

NEO / Nep5 Tokens: AYbHEah5Y4J6BV8Y9wkWJY7cCyHQameaHc

License

MIT

backmeup's People

Contributors

ardakilic avatar islander avatar techsailor avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

backmeup's Issues

Alternative - duply

Hello,

By analysis use cases and missing features I would like add info about alternative duply. It's python script.

It support all uses case:

  • The script dumps all of your MySQL databases individually. - Yes, through by pre script
  • The script backs up all of your Web files (e.g: root of all of your virtual hosts). - Yes.
  • The script compresses your web-root and databases to a single archive. - It does it better because it splits into multiple archives, which secures itself against transmission problems.
  • The script uploads the compressed archive into a folder in your Dropbox account, Amazon S3 bucket or Owncloud Server.
  • If the method is set to dropbox, The script makes sure that you always have the newest Dropbox-Uploader script. - Not applicable.
  • After the upload, the script cleans up the temporary files (dumps, the archive itself). - Works better because it stores only a portion of the archive at a time.

It support all missing features:

  • Tests on CentOS, Arch etc. - Yes, a lot of distro ships packages.
  • Mega.nz integration - Yes.
  • Owncloud Integration - Yes.
  • AWS S3 integration - Yes.
  • Increased security? - Yes, encryption.
  • Reading configuration from an external file - Yes.
  • Postgres support - Yes, throught pre script.
  • Option to dump only the database(s) or only Virtualhost files - Yes.
  • Multiple Virtualhost folder support - Yes, dump any target as you want.

Greetings,

password character escape

If you have a password with "!" or other character this is not working. How about you escape the $DBPASSWORD inside the backtick?

Idea: Rewrite Using Docker

If you're going docker way, this tool could easily be re-written from scratch, using dedicated tools such as rclone etc, with the same functionality.

Please upvote this message if you'd like to have it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.