Git Product home page Git Product logo

backup-wordpress's Introduction

Backup-Wordpress

Scripts to backup WordPress via server cron (cPanel, Plesk, etc)

There are plenty of plugins available to take backups within WordPress. However, the scripts mentioned here work outside WordPress making them much more effective and efficient. If you take offline backups, I highly recommend to use encryption and limit your offline storage to only allow one-way backups.

Features

  • No plugin to install. So, no plugin conflicts!
  • Single script to take backups of multiple sites.
  • Separate script to take (nightly) files backup without uploads directory!
  • Local and offline backups are supported.
  • Automatic deletion of local backups.
  • Support for sub-directory installation of WordPress!
  • Support for simple encryption using GnuPG
  • Alert via email when the offsite backup fails (and succeeds)

Wishlist

  • take only local backups or only remote backups or both.
  • ability to remove local backups when taking only remote backups.
  • single script to take all sorts of backups.
  • close integration with wp-cli (probably as a plugin).
  • alert when local storage reaches a limit.

Requirements in the server

  • wp-cli
  • aws-cli and/or gsutil (optional, to take offline backups)
  • SSH access
  • mysqldump
  • tar
  • enough disk space to hold local backups
  • gpg for encrypted backups (optional, but helps to comply with GDPR).

What does each backup script do?

  • db-backup.sh can take database backup with --add-drop-table option.
  • files-no-uploads-backup.sh can take files backups without uploads folder to reduce the overall size of the backup. Ideal for nightly backups!
  • full-backup.sh can take full backup including database (that is named db.sql and is available at the WordPress core directory). Ideal for a weekly routine!

Where are the backups stored?

  • local backups are stored in the directory named ~/backups/. If it doesn't exist, the script/s would attempt to create it before execution.
  • offline backups can be stored in AWS (for now). Support for other storage engines (especially for GCP) is coming soon!

Usage

  • You may configure most things on the command line since version 6.0.0. For usage, just run the script without arguments.
  • If you use older version of the script (older than 6.0.00, firstly, go through each script and fill-in the variables to fit your particular environment. Currently, it is assumed that the WordPress core is available at ~/sites/example.com/public.
  • please adjust the number of days to keep the backup, depending on the remaining hard disk space in your server.
  • test the scripts using SSH before implementing it in system cron.
  • note: you may take backups of multiple domains like the following...
/path/to/db-backup.sh example1.com
/path/to/db-backup.sh example2.com
/path/to/db-backup.sh example3.com

For more usage options, please run /path/to/db-backup.sh -h.

The above is applicable to all the scripts!

Contributors

Thanks to the following people who have contributed to this repo...

How to decrypt, if I used a passphrase

gpg --batch --passphrase your_passphrase encrypted_file.tar.gz.gpg

Can you implement it on my server?

Yes, of course. But, for a small fee of USD 5 per server per site. Reach out to me now!.

I have a unique situation. Can you customize it to suit my particular environment?

Possibly, yes. My hourly rate is USD 50 per hour, though.

Have questions or just wanted to say hi?

Please ping me on Twitter or send me a message.

Suggestions, bug reports, issues, forks are always welcome!

backup-wordpress's People

Contributors

cicciodev avatar nik-lampe avatar pothi avatar wischweh 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

backup-wordpress's Issues

readme: twitter username has a ']'

Please ping me on [Twitter](https://twitter.com/pothi]) or [send me a message](https://www.tinywp.in/contact/).

to

Please ping me on [Twitter](https://twitter.com/pothi) or [send me a message](https://www.tinywp.in/contact/).

Amazing work on the scripts!

idea: add rclone support, would open up a ton of options for backup locations.

unary operator expected

Debug output...

+ DEFAULT_SITE=delta9seattle.org
+ BACKUP_PATH=/home/delta9seattle_sftp/Backup/databases/
+ '[' == '' ']'
./db-backup.sh: line 15: [: ==: unary operator expected
+ SITE_NAME=
+ '[' -f /home/delta9seattle_sftp/sites//wp-config.php ']'
+ WP_CONFIG_PATH=/home/delta9seattle_sftp/sites//wordpress/wp-config.php
++ sed 's/[()'\'',;]/ /g' /home/delta9seattle_sftp/sites//wordpress/wp-config.php
++ awk '{print $3}'
sed: can't read /home/delta9seattle_sftp/sites//wordpress/wp-config.php: No such file or directory
++ grep DB_PASSWORD
+ WPPASS=
++ sed 's/[()'\'',;]/ /g' /home/delta9seattle_sftp/sites//wordpress/wp-config.php
++ awk '{print $3}'
sed: can't read /home/delta9seattle_sftp/sites//wordpress/wp-config.php: No such file or directory
++ grep DB_USER
+ WPUSER=
++ sed 's/[()'\'',;]/ /g' /home/delta9seattle_sftp/sites//wordpress/wp-config.php
++ awk '{print $3}'
sed: can't read /home/delta9seattle_sftp/sites//wordpress/wp-config.php: No such file or directory
++ grep DB_NAME
+ WPDB=
+ mysqldump --add-drop-table -u -p
+ gzip
++ date +%F_%H-%M-%S

Add encryption to backup

Hello Pothi,
First of all I would like to thank you since I've found your project really useful.
I live and work in Europe so cause of the new GDPR rules (a law that enforces privacy and data processing) I've forked your work and added the option to encrypt(simple encryption using gpg) backup before sending it to aws.
I don't know if it might be interesting for you, if so here the commit link: Cicciodev@cb18f5e

Have a nice day

Merge all backup scripts

So, in the end, the backup script should simply be called wp-backup or backup-wp with the following options...

wp-backup -d (or --database) (for db backups)
wp-backup --db --files (or) wp-backup --files --db (for full backups)
wp-backup (-f) --files --exclude-uploads (or --no-uploads or --without-uploads) (for partial backups)

wp-backup -l (or --local for local backups)
wp-backup -r (or --remote for remote backups) (or) wp-backup -o (for offline backups)

wp-backups -r -a aws_bucket_name (or --aws)
wp-backups -r -g gcp_bucket_name (or --gcp)

Specify domain as a switch?

Hi Dude!

Is it possible to specify the domain as a switch e.g:

$ ./full-backup.sh --domain example2.com
$ ./full-backup.sh --domain example3.com

Etc.

If you can help it would be appreciated! Love the script BTW :D

Matt

Use wp-cli to take backups

And stop using the old method. wp-cli is present in almost every host or it could be installed easily, even in GoDaddy. โžฐ

Report backup size in output

Hello, I would find it useful for the command to output stats on the backup size.

After the "Latest backup is at" line
Backup size [bytes]: X
Backup size [Human]: Y

Where Human = du -h mode.

And if you wanted to be really fancy include the unencrypted size and the compression ratio.

This would just make it easier to have an awareness of the backup size.

I think this should go out in the success email also.

Thanks

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.