=== Zip 4 Me ===
Contributors: yewaung
Tags: backup, restore, migration, clone, s3
Requires at least: 5.6
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 0.9.0
License: GPLv3 or later
License URI: https://www.gnu.org/licenses/gpl-3.0.html

Backup, restore and migration by TheStickPress, with a secure Site to Site Bridge to push or pull a whole site.

== Description ==

Zip 4 Me backs up, restores and moves WordPress sites on any host, in small steps, without other plugins.

= Features =
* Back up the whole site (wp-content and the database) into one .zipme file.
* Restore on the same site or migrate to another URL: links, file paths and table prefix are updated, including inside serialized data.
* Upload backups of any size: the browser sends them in pieces smaller than PHP's upload limit.
* S3-compatible storage (Amazon S3, Cloudflare R2, Backblaze B2, Wasabi, DigitalOcean Spaces, MinIO, ...) and FTP / FTPS.
* Google Drive and OneDrive through your own Google or Microsoft app: Zip 4 Me sees only its own folder, and no TheStickPress server sits in between.
* Scheduled backups through WP-Cron, with retention and an email on failure.
* Site to Site Bridge: pair two sites once, then push this site to the other or pull the other into this one, with no files to download. Signed, encrypted, and open only while both sites allow it.
* A safety snapshot before a Site to Site restore, kept 24 hours, so you can roll back.

Screen: TheStickPress > Zip 4 Me, with the tabs Backup, Import, Export, Schedule backup, Site to Site, Other Storage and Settings.

= How it works =
Every backup or restore is a job split into steps that run in slices of about 20 seconds, so large sites never hit PHP's time limit. Job state is kept in files under wp-content/zip4me/jobs, not in the database, because a restore replaces the database while it runs.

Backup: list files, dump the database table by table, write everything into the archive in 1 MiB blocks, each with its own CRC32 checksum.

Restore: check the archive, extract files (paths that try to leave wp-content are refused), load the database into temporary tables, replace URLs and paths, then swap all tables in with one RENAME TABLE statement. If anything fails before the swap, the temporary tables are dropped and the live site is untouched. Afterwards WordPress' database update runs if the backup came from an older WordPress.

Kept from the current site on restore: its URL, Zip 4 Me itself and Zip 4 Me's settings, and the Site to Site identity, pairings and activity log.

= Files =
wp-content/zip4me/backups   finished .zipme backups (web access blocked; download from the Backups page)
wp-content/zip4me/jobs      running and recent jobs (removed after two days)
wp-content/zip4me/bridge    this site's bridge key pair, paired sites, open windows, activity log, copies arriving from a paired site

= Upgrading from ZipWP or AIODUP =
Zip 4 Me is the new name of ZipWP, which was earlier called AIODUP. Install Zip 4 Me, then deactivate and delete the old plugin.

* Old .zipwp and .aiodup backups can still be uploaded and restored (same format, older headers).
* On first run Zip 4 Me copies the old plugin's settings.
* Backups in wp-content/zipwp/backups or wp-content/aiodup/backups are not moved. Move the ones you want to keep into wp-content/zip4me/backups.

= Site to Site Bridge =
1. On both sites open Site to Site, click "Show bridge code" and paste each code into the other site.
2. Check that both screens show the same 6 digit safety number, then confirm with your WordPress password.
3. On the site that will be replaced or copied, turn on "May replace this site" or "May copy this site" for the other site.
4. Click Open Bridge on both sites (1, 6 or 24 hours), then Push or Pull.

Security:
* Each site has its own Ed25519 key pair. The private key never leaves the server and is never shown. A bridge code holds only the address and public key, is signed by the site and expires after 15 minutes.
* Every request and every answer is signed, expires after 5 minutes and can be used once. Repeated bad requests from one address are blocked for an hour.
* The site copy is encrypted piece by piece (XChaCha20-Poly1305) on top of HTTPS, and its SHA-256 checksum is checked before anything is restored.
* HTTPS by default. To connect to a site without HTTPS (for example a local site), turn on "Allow plain http" in Settings on the site that starts the transfer. The copy stays encrypted and signed; only addresses and sizes can be seen on the network.
* Daily limits per paired site (default 2 pushes accepted and 2 copies served), an email to the admin when another site pushes or copies, and an activity log kept outside the database.

The site that starts a transfer always opens the connection, so a development site on your computer can push to and pull from a live site.

= Limits =
* Single-site WordPress only (no multisite).
* Cannot read .wpress files from All-in-One WP Migration.
* WordPress core files and wp-config.php are not included, only wp-content and the database.
* Symbolic links inside wp-content are skipped.
* Values stored as serialized PHP objects of classes other than stdClass keep their old URLs.
* Google Drive and OneDrive need your own app (free, about 5 minutes; the Other Storage tab shows the steps). Dropbox is not included.
* FTP needs the PHP ftp extension. The database needs the mysqli driver (standard in WordPress).

== Installation ==

1. Upload the `zip4me` folder to `/wp-content/plugins/`, or install the ZIP in Plugins > Add New > Upload.
2. Activate the plugin and open TheStickPress > Zip 4 Me.
3. Press "Zip it now" for your first backup.

== Frequently Asked Questions ==

= How big can a backup be? =

Any size: backups and uploads are handled in small steps and pieces.

= Can I move my site to another address? =

Yes. Restore the backup on the new site; links, paths and the table prefix are updated.

== External services ==

Only when you set them up: backups are sent to the S3-compatible storage you configure (for example Amazon S3; terms https://aws.amazon.com/service-terms/ , privacy https://aws.amazon.com/privacy/ ), to the FTP server you configure, to Google Drive when you connect it (Google APIs; terms https://developers.google.com/terms , privacy https://policies.google.com/privacy ), to OneDrive when you connect it (Microsoft Graph; terms https://www.microsoft.com/servicesagreement , privacy https://privacy.microsoft.com/privacystatement ), or between this site and a WordPress site you paired on the Site to Site tab. What is sent: the backup file (your site's files and database), encrypted between paired sites. Nothing is sent otherwise.

== Screenshots ==

1. Back up to this server, S3, FTP, Google Drive or OneDrive in one click.
2. Your backups: restore, download or delete; restore from a file of any size.
3. Settings: storage, schedule and how many backups to keep.

== Changelog ==

= 0.9.0 =
* New: Google Drive and OneDrive storage through your own Google or Microsoft app. Back up to them, restore from them, schedule backups to them and keep only the newest ones. Google Drive uses the drive.file access (only the Zip 4 Me folder); OneDrive uses its own app folder.
* Changed: the WordPress password is asked only when two sites are paired. Open Bridge, permissions, Disconnect, Push and Pull no longer ask for it.
* Changed: Push and Pull have their own sections on each paired site, with the direction, what gets replaced and the switch the other site needs.
* Fixed: cards side by side line up, and fields and buttons have space between them.
* Fixed (code review): checksums of large copies are worked out in pieces so big sites do not time out; a transfer that started can finish after this site's bridge window closes; old snapshots and pulled copies are cleared on any site, not only on the one that answers; a failed restore removes the copy it received; a repeated restore call cannot start a second restore; waiting for the other site no longer keeps a PHP worker asleep; Google Drive resumes a partly kept piece from the right byte; Drive and OneDrive downloads look the file up once; old bad-request records are removed.
* Changed: deleting the plugin also removes this site's Site to Site key, pairings and activity log (backups stay).

= 0.8.0 =
* New: Site to Site Bridge. Pair two sites with signed codes and a safety number, then push or pull a whole site in either direction, with no files to download. Each site has its own Ed25519 key pair; requests and answers are signed and used once; the copy is encrypted piece by piece and checked with SHA-256; transfers resume after a dropped connection.
* New: the bridge works only while both sites have clicked Open Bridge (1, 6 or 24 hours), with separate permissions for "May replace this site" and "May copy this site", daily limits, admin emails and an activity log.
* New: a safety snapshot before every Site to Site restore, kept 24 hours, and a short "back soon" page for visitors while the restore runs.
* New: one screen with tabs: Backup, Import, Export (with download), Schedule backup, Site to Site, Other Storage and Settings. The old Settings address redirects.
* Changed: chunk sizes and limits suit the smallest shared hosting (30 second requests, 8 MB uploads).
* Removed: the version 1 direct push and its shared connection key. Pair the sites again on the Site to Site tab.

= 0.6.0 =
* Fix: a restore stopped at "Could not write ... .git/..." on Windows. Version-control folders (.git, .svn, .hg) are no longer backed up or restored, read-only files are made writable before they are replaced, and a file that is briefly locked is tried again (also for the job's progress file).
* Fix: the first page after a restore could fail with "Cannot redeclare class TheStickPress_Hub_1". The shared menu class is now declared safely, and the PHP code cache is cleared at the end of a restore.
* Recoloured to the TheStickPress lime and ink look, with the 4ME icon in the header.
* A tooltip on "Your backups" explains which backups are kept: manual ones always, scheduled ones only the newest few.

= 0.5.2 =
* New 4ME icon (TheStickPress family) in assets/brand (SVG, 128 and 256 px) and on the TheStickPress overview.

= 0.5.1 =
* Shared "TheStickPress" admin menu: the settings are now under TheStickPress (old addresses redirect).
* Coding standards: translator comments, documented file streaming and database dump, safer upload checks, clearer names.

== Upgrade Notice ==

= 0.9.0 =
Adds Google Drive and OneDrive storage, and a simpler Site to Site screen.

= 0.8.0 =
New Site to Site Bridge (push and pull) and a tabbed screen. Old direct push connection keys stop working: update both sites to 0.8.0 and pair them on the Site to Site tab.

= 0.6.0 =
Part of the 4 Me family by TheStickPress. See the changelog for what is new.
