py-wordpress-backup
A Python package for backing up and restoring a self-hosted WordPress installation, including the database and uploaded content.
The backup file will contain:
- Your database as a MySQL dump.
- An exact copy of your entire WordPress directory.
The restore process will:
- Extract the files into the correct location
- Update
wp-config.phpwith new settings (if needed) - Create the database if it doesn't exist
- Add the user and grant it access if it doesn't exist
- Restore the database
Credit
Credit for the original version of this goes to Cariad Eccleston.
TODO
- Unit tests.
- Handle
wp-config.phpbeing somewhere other than the default location.
Installation
pip install wpbackup2
Usage
To backup:
python3 -m wpbackup2 backup --wp-dir /www/wordpress --archive ~/backup.tar.gz
Note that the current release of py-wordpress-backup expected wp-config.php to exist within your WordPress directory, and will use it to read your database credentials to perform the backup. Keeping your wp-config.php file in this location might not be the best practice, and I'll likely handle this in a future update.
To restore using database admin credentials held in AWS Secrets Manager:
python3 -m wpbackup2
restore
--wp-dir /www/wordpress
--archive ~/backup.tar.gz
--admin-credentials-aws-secret-id AdminUserSecretID
--admin-credentials-aws-region eu-west-1
To restore with specified database admin credentials:
python3 -m wpbackup2
restore
--wp-dir /www/wordpress
--archive ~/backup.tar.gz
--admin-user admin
--admin-password trustno1
--new-site-url https://new.site.url
--new-site-host https://new.site.url
--new-db-host
--new-db-port 3306
--new-db-name new-wordpress-db-name
Development
import wpbackup2
wp = WpBackup()
wpbackup('path to wordpress', 'archive name')
Prerequisites
py-wordpress-backup requires Python 3.6 or newer.
Installing dependencies
pip install -e .[dev]
Metadata
Release files for wpbackup2 0.2.21
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| wpbackup2-0.2.21.tar.gz | 10.9 kB | Without provenance | Details for wpbackup2-0.2.21.tar.gz |
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| wpbackup2-0.2.21-py3.8.egg | Legacy Egg format | - | - | Details for wpbackup2-0.2.21-py3.8.egg |
| wpbackup2-0.2.21-py3-none-any.whl | Python 3 | none | any | Details for wpbackup2-0.2.21-py3-none-any.whl |
Total release size: 57.2 kB
Release files / wpbackup2-0.2.21.tar.gz
| Download URL | wpbackup2-0.2.21.tar.gz |
|---|---|
| Size | 10.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f49677365ce61894c72899ae7fba262827450869b2d948bb87a27cd8735cb566
|
|
BLAKE2b-256 checksum How to use checksums |
801836cb8c945b9afd923910723e236a7a9f9b759f5efc5b9fff589d036ad16e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.5
|
Release files / wpbackup2-0.2.21-py3.8.egg
| Download URL | wpbackup2-0.2.21-py3.8.egg |
|---|---|
| Size | 31.3 kB |
| Tags | Egg |
|
SHA-256 checksum How to use checksums |
7cfba22a6ec42c32d5af3246cd36d5fcad53e817e3e47e2e0e09cd87d503d7b4
|
|
BLAKE2b-256 checksum How to use checksums |
6da299e0403d3a5c711af74328a9d17340e3cc47cd9c291c93067a69b09a7827
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.5
|
Release files / wpbackup2-0.2.21-py3-none-any.whl
| Download URL | wpbackup2-0.2.21-py3-none-any.whl |
|---|---|
| Size | 15.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5e70864dce2e6286c3a6ff1fec532cedc2a25fcebe23eaafda71aa33be3bfd13
|
|
BLAKE2b-256 checksum How to use checksums |
fc5785d413b044003f3e0139d3c96ce0e5d129a21c08909407c9c25668181b2c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.5
|
Security for wpbackup2 0.2.21
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.