Files

2.4 KiB
Raw Permalink Blame History

Snapshot and backups for WordPress in pure Bash

logo

Create backups or restores on your WordPress using a simple Bash script and don't rely on plugins or WP-CLI.

Why should I use it?

  • Easy.
  • Very fast.
  • Multi-site compatible.
  • Docker compatible.
  • Working with cron and any unix utility.
  • Maintains settings, plugins and any important elements.
  • Compatible with Linux, MacOS and BSD.

Use

Backup ⬇️ 📁 ⬇️ 📓

Create a zip file with important files and backup of the database.

./wp-backup.sh backup-all

Backup only database ⬇️ 📓

./wp-backup.sh backup-database

Restore only files ⬇️ 📁

./wp-backup.sh restore-files [{backup}.zip]

Restore only database ⬆️ 📓

./wp-backup.sh restore-database [{database}.sql]

Restore files and database ⬆️ 📁 ⬆️ 📓

./wp-backup.sh restore-all [{backup}.zip]

Check the connection to the database 📓

./wp-backup.sh check-database

Connection to the database 🔌 📓

./wp-backup.sh connect-to-database

Requirements

  • bash 4.0 or higher
  • curl
  • zip
  • Only macOS users, gsed: brew install gnu-sed

Install

Go to the WordPress directory (Where are all the files and folders like wp-admin, wp-config, wp-content ...).

cd wordpress-folder

Download script.

curl -o wp-backup.sh https://raw.githubusercontent.com/tanrax/wp-backup/master/wp-backup.sh

Grant execute permissions.

sudo chmod +x wp-backup.sh

Run.

./wp-backup.sh

Are you using Docker?

Enter the container with bash. For example wordpress_web_1.

docker exec -it wordpress_web_1 bash

You will need to enter the WordPress container and install a minimum of unix commands.

  • zip
  • unzip
  • mariadb-client
apt update && apt install -y mariadb-client zip unzip

Run wp-backup.sh inside container.

./wp-backup.sh

Contributing

Contributions are welcome! Please see the contribution guidelines for instructions on how to submit issues or pull requests.

Disclaimer

The author is not responsible for any loss of information or side effects. Use at your own risk.