=== Site Backup & Migration – Backup, Restore, Migrate & Clone WordPress ===
Contributors: webangon
Tags: backup, restore, migration, migrate, clone
Requires at least: 4.7
Requires PHP: 7.0
Tested up to: 7.1
Stable tag: 1.1.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Free WordPress backup, restore and migration. Back up your database and files, then restore or move your site. Large uploads work on 2 MB hosting limits.

== Description ==

**Site Backup & Migration** is a lightweight, free **WordPress backup and restore plugin** for backing up your site and moving it to a new host or domain. Large backup files can be imported without paid add-ons.

Most hosts limit uploads to 2–64 MB, which blocks importing a large backup. This plugin uploads archives in small **adaptive chunks**, so a 500 MB or 2 GB backup imports even when the host only allows 2 MB uploads. You don't need to edit `php.ini` or `.htaccess`, or buy an "unlimited" extension.

= Why choose Site Backup & Migration? =

* **No upload size limit** – adaptive chunked upload bypasses `upload_max_filesize`, `post_max_size` and web server body limits (nginx `client_max_body_size`, ModSecurity). The chunk size shrinks automatically on HTTP 413 or timeouts and grows on fast connections.
* **No timeout failures** – backups, restores and uploads run step by step, so slow shared hosting doesn't hit `max_execution_time`.
* **Safe restore** – the database is restored into temporary tables first, so a failed restore leaves your live site untouched.
* **Automatic URL replacement** – migrate to a new domain, from localhost to live, or from staging to production. Site URLs are replaced automatically, including in serialized data.
* **Google Drive & Dropbox backup** – send every backup off-site automatically with resumable chunked uploads, and optionally delete the local copy afterwards.
* **Scheduled automatic backups** – twice daily, daily, weekly or monthly, with automatic cleanup that keeps only the last N scheduled backups.
* **Content backup or full backup** – back up only the database and media library, or everything including plugins and themes.
* **Import from a URL** – pull a backup straight from another server, with resumable chunked downloads.
* **Works on any host** – uses PHP ZipArchive when available and falls back to WordPress's built-in PclZip.
* **Lightweight and free** – no frameworks or external libraries, no account, no upsells for basic features.

= Use cases =

* **Backup WordPress** before updates, theme changes or plugin installs.
* **Migrate WordPress** to a new host or domain.
* **Clone a site** for staging, testing or a client copy.
* **Move localhost to live** (Local, Laragon, XAMPP, MAMP) and back.
* **Ship demo content** – export a content package for a theme or client site.
* **Restore a site** after a broken update, hack or mistake.

= Features =

* **Content backup** – database + uploads, a portable demo/content package.
* **Full backup** – database + uploads + plugins + themes.
* **Cloud storage** – Google Drive and Dropbox (your own app, tokens stay on your site), with cloud retention and one-click restore from the cloud.
* **Backup scheduler** – automatic backups at a chosen time, with retention (keep last N) and run status.
* **One-click restore** – restores the database (with site-URL replacement) and files from any archive made by this plugin.
* **Download backups** – download archives to your computer for safe keeping.
* **Upload / import backups** – adaptive chunked upload with automatic retry and resume.
* **Import from URL** – resumable chunked transfer from a remote server.
* **Resumable engine** – background (loopback) processing. If loopback is blocked, the admin page keeps the process moving.
* **Protected storage** – backups are stored in a folder protected by `index.php` and `.htaccess`.

== Installation ==

1. Install from **Plugins → Add New** by searching for "Site Backup & Migration", or upload the zip.
2. Activate the plugin.
3. Open **Site Backup** in the admin menu.
4. Click **Content backup** or **Full backup**, then download the archive.
5. To migrate, install the plugin on the new site, upload the archive and click **Restore**.

== Frequently Asked Questions ==

= How do I migrate my WordPress site to a new host or domain? =

Create a full backup on the old site and download it. Install WordPress and this plugin on the new site, upload the archive in **Site Backup**, then click **Restore**. URLs are replaced automatically.

= My host limits uploads to 2 MB. Can I still import a large backup? =

Yes. The archive is sent in small chunks that each fit under the limit. If the server rejects a chunk (HTTP 413) or times out, the plugin automatically retries with a smaller chunk.

= Is there a maximum backup size? =

The upload itself has no plugin limit. The practical limit is your disk space, and archives over 2 GB need 64-bit PHP.

= Will a failed restore break my site? =

The database is imported into temporary tables and swapped in only when the import succeeds. A failed database restore leaves your live tables untouched.

= What is the difference between a content backup and a full backup? =

A content backup includes the database and the uploads folder, which suits moving content or shipping a demo. A full backup also includes plugins and themes, for a complete site clone.

= Can I move a site from localhost to a live server? =

Yes. Back up the local site, then upload and restore it on the live site. Local URLs are replaced with the live URL.

= Where are backups stored? =

In `wp-content/uploads/webangon-site-backup/`, protected by `index.php` and `.htaccess`. Archives are standard `.zip` files containing `database.json.txt` and an `f/` folder with your files.

= Does it need the PHP Zip extension? =

No. ZipArchive is used when available because it is faster. Otherwise the plugin falls back to PclZip, which ships with WordPress.

= Can I schedule automatic backups? =

Yes. In **Site Backup → Backup schedule**, choose twice daily, daily, weekly or monthly, a start time, the backup type and how many scheduled archives to keep. Older scheduled archives are deleted automatically. Manual backups are never removed. Scheduled backups use WP-Cron. If your host disables WP-Cron, add a server cron job that calls `wp-cron.php`.

= Can I back up to Google Drive or Dropbox? =

Yes. In **Site Backup → Cloud storage**, add your own free Google or Dropbox app credentials, click **Connect** and approve access. Every new backup (manual and scheduled) is then uploaded automatically using resumable chunked uploads, so large archives work on slow or limited hosting. You can also delete the local copy after a successful upload to save disk space.

= Why do I need my own Google / Dropbox app? =

Your access tokens stay on your own site, and nothing passes through a third-party relay server. Creating an app is free and takes a few minutes. Copy the redirect URI shown in the plugin into the app's settings.

= How do I restore a backup stored in the cloud? =

In **Cloud storage**, click **Show cloud backups**, then **Download & restore** next to the archive. The plugin pulls it back to your server in resumable chunks and starts the restore. It works on a fresh WordPress install too: install the plugin, connect the same account, and restore.

= Can old cloud backups be deleted automatically? =

Yes. Set **Keep the last N backups in each cloud account**. After each successful upload, older archives of this site are deleted from Google Drive / Dropbox. Archives from other sites in the same account are never touched.

== Screenshots ==

1. Backup dashboard – create content or full backups and manage archives.
2. Upload or import a backup – adaptive chunked upload with live progress.
3. Backup schedule – automatic backups with retention.
4. Cloud storage – connect Google Drive and Dropbox.

== Requirements ==

* PHP 7.0+ (64-bit recommended for archives over 2 GB).
* PHP ZipArchive (preferred) or zlib for the PclZip fallback.
* HTTP loopback recommended. Without it, keep the admin page open during an operation.

== External services ==

This plugin connects to external services **only** when you connect a cloud destination in **Site Backup → Cloud storage**. Nothing is sent before you connect an account.

**Google Drive (Google LLC)** – used to store copies of your backup archives in your own Google Drive.
* When you click Connect, you are sent to Google to sign in and approve access (`accounts.google.com`). The authorization code, your client ID and client secret are then exchanged for tokens at `oauth2.googleapis.com`.
* After each backup, the archive file (your database and files) and its filename are uploaded to `www.googleapis.com`. The plugin also reads your account email to show which account is connected, and creates a backup folder.
* When you open the cloud backup list, or retention is enabled, the plugin lists the files in that folder and deletes old archives of this site. When you restore from the cloud, the chosen archive is downloaded from `www.googleapis.com`.
* On disconnect, the token is revoked at `oauth2.googleapis.com/revoke`.
* Terms: https://policies.google.com/terms – Privacy: https://policies.google.com/privacy

**Dropbox (Dropbox, Inc.)** – used to store copies of your backup archives in your own Dropbox.
* When you click Connect, you are sent to `www.dropbox.com` to approve access. Tokens are obtained from `api.dropboxapi.com` using your app key (PKCE, no secret stored).
* After each backup, the archive file and its filename are uploaded to `content.dropboxapi.com`. The plugin also reads your account email to show which account is connected.
* When you open the cloud backup list, or retention is enabled, the plugin lists the app folder and deletes old archives of this site (`api.dropboxapi.com`). When you restore from the cloud, the chosen archive is downloaded from `content.dropboxapi.com`.
* On disconnect, the token is revoked at `api.dropboxapi.com`.
* Terms: https://www.dropbox.com/terms – Privacy: https://www.dropbox.com/privacy

== Notes ==

* A **full restore** of plugins and themes needs filesystem write access. On hosts without direct access, set `FS_METHOD` / `FTP_*` in `wp-config.php`. Content restores (database + uploads) don't need this.
* Uninstalling removes the plugin's options but keeps your backup archives.

== Changelog ==

= 1.1.0 =
* New: Google Drive and Dropbox cloud backup with resumable chunked uploads.
* New: cloud retention – keep the last N backups per cloud account.
* New: restore from the cloud – list cloud backups and download & restore in one click.
* New: scheduled automatic backups (twice daily, daily, weekly, monthly) with retention. Manual backups are never pruned.
* New: adaptive chunked upload. The chunk size shrinks automatically on HTTP 413 or gateway timeouts and grows on fast connections, so large backups import on hosts with 2 MB upload limits.
* New: the browser remembers the working chunk size for each site.
* Improved: upload requests raise the PHP time limit and memory limit where the host allows.
* Improved: chunks are addressed by byte offset, so retries stay safe when the size changes mid-upload.
* Renamed to "Site Backup & Migration".

= 1.0.0 =
* Initial release with content/full backup, restore, download, upload/import, and a responsive backup-management dashboard.

== Upgrade Notice ==

= 1.1.0 =
Adds Google Drive and Dropbox cloud backup and scheduled automatic backups. Large backups now upload reliably on hosts with small upload limits (2 MB) and nginx/ModSecurity body limits.
