Coder Social home page Coder Social logo

impiza / wordpress-db-code-backup-bash-script Goto Github PK

View Code? Open in Web Editor NEW

This project forked from magepsycho/wordpress-db-code-backup-bash-script

0.0 1.0 0.0 174 KB

Bash Script: Backup Wordpress Code + Database

Home Page: https://blog.magepsycho.com

Shell 100.00%

wordpress-db-code-backup-bash-script's Introduction

Bash Script: Backup Wordpress Code + Database

This utility script helps you to backup Wordpress code and database.
You can either run the command manually or can automate it via cronjob.

INSTALL

You can simply download the script file and give the executable permission.

curl -0 https://raw.githubusercontent.com/MagePsycho/wordpress-db-code-backup-bash-script/master/src/wp-db-code-backup.sh -o wp-backup.sh
chmod +x wp-backup.sh

To make it system wide command

sudo mv wp-backup.sh /usr/local/bin/wp-backup

USAGE

To display help

./wp-backup.sh --help

To backup database only

./wp-backup.sh --backup-db --src-dir=/path/to/wp/root --dest-dir=/path/to/destination

If you want to get rid of this message

Using a password on the command line interface can be insecure.

You can create a .my.cnf file in home directory with the following config

[client]
host=localhost
user=[your-db-user]
password=[your-db-pass]

And use option --use-mysql-config as

./wp-backup.sh --backup-db --use-mysql-config --src-dir=/path/to/wp/root --dest-dir=/path/to/destination

To backup code only

./wp-backup.sh --backup-code --skip-uploads --src-dir=/path/to/wp/root --dest-dir=/path/to/destination
  • You can omit --skip-uploads option if you want to include wp-content/uploads folder in backup archive

To backup code + database

./wp-backup.sh --backup-db --backup-code --skip-uploads --src-dir=/path/to/wp/root --dest-dir=/path/to/destination

You can omit --src-dir option if you are running the script as system-wide command from root folder of wordpress

To schedule backup via Cron

If you want to schedule via Cron, just add the following line in your Crontab entry crontab -e

0 0 * * * /path/to/wp-backup.sh --backup-db --backup-code --use-mysql-config --skip-uploads --src-dir=/path/to/wp/root --dest-dir=/path/to/destination > /dev/null 2>&1

0 0 * * * expression means the command will run run at every midnight.

Screenshots

Wordpress Backup in Action Wordpress backup script

TO-DOS

  • Rotation for backups
  • Enable remote backups
    • S3
    • Google Drive
    • Dropbox

wordpress-db-code-backup-bash-script's People

Contributors

magepsycho avatar

Watchers

James Cloos avatar

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.