97 lines
3.5 KiB
Markdown
97 lines
3.5 KiB
Markdown
# SiteGround SFTP Backup Pattern
|
|
|
|
Back up websites from SiteGround shared hosting to Wasabi S3 via SFTP. SiteGround does not expose an API — SFTP is the only programmatic access method.
|
|
|
|
## Credentials
|
|
|
|
- Host: `sftp.siteground.net`
|
|
- Port: `18765` (non-standard)
|
|
- Username: `sftp7068-6b4804d3`
|
|
- Key: encrypted RSA private key with passphrase `LoveMyBoys73!`
|
|
- The key file lives at `/root/.ssh/siteground.key` (chmod 600)
|
|
|
|
## Connection Method
|
|
|
|
SiteGround uses an **encrypted RSA private key with a passphrase**. Plain key-based auth without the passphrase will fail. Two approaches:
|
|
|
|
### A. Python + Paramiko (preferred for scripting)
|
|
|
|
```python
|
|
import paramiko, io
|
|
|
|
key = paramiko.RSAKey.from_private_key(io.StringIO(key_data), password="<passphrase>")
|
|
transport = paramiko.Transport(("sftp.siteground.net", 18765))
|
|
transport.connect(username="sftp7068-6b4804d3", pkey=key)
|
|
sftp = paramiko.SFTPClient.from_transport(transport)
|
|
```
|
|
|
|
### B. sshpass + ssh (manual/scripting)
|
|
|
|
Not recommended for scripting due to passphrase-in-command exposure, but valid for manual testing:
|
|
|
|
```bash
|
|
sshpass -p "<passphrase>" ssh -i /root/.ssh/siteground.key \
|
|
-o StrictHostKeyChecking=no -o PubkeyAuthentication=yes \
|
|
-p 18765 sftp7068-6b4804d3@sftp.siteground.net "ls -la"
|
|
```
|
|
|
|
## Sites Present (Jul 2026)
|
|
|
|
21 sites — all WordPress, all under `/home/` on SiteGround:
|
|
|
|
815bistro.com, abortionstory.org, apextrackexperience.com, chiefenergyofficer.org, costanzospizzeria.com, elliscountyinternet.com, fixourclub.com, forefrontwireless.com, forefrontwireless.net, freedominhonesty.com, garyjavo.com, germainebrown.com, grandlakeclub.com, injenuity413.com, injenuitysolutions.com, itpropartner.com, katiewattsdesign.com, savannahevents.com, sotobunch.com, theabortionstory.org, voipsimplicity.com
|
|
|
|
## Backup to S3
|
|
|
|
Each site is a full directory tarball uploaded to `s3://hermes-vps-backups/siteground/<site>/`:
|
|
|
|
```python
|
|
import tarfile, io
|
|
|
|
# Stream tar.gz to S3 to avoid filling /tmp on large sites
|
|
buf = io.BytesIO()
|
|
with tarfile.open(fileobj=buf, mode='w:gz') as tar:
|
|
tar.add(f"/home/{site}", arcname=".")
|
|
buf.seek(0)
|
|
|
|
# Upload directly
|
|
s3_client.upload_fileobj(buf, "hermes-vps-backups", f"siteground/{site}/{site}-{date}.tar.gz")
|
|
```
|
|
|
|
For very large sites (apextrackexperience.com, itpropartner.com, voipsimplicity.com), write to `/tmp` first then upload — streaming through memory may timeout on SFTP.
|
|
|
|
## Exclusion Recommendations
|
|
|
|
WordPress sites on SiteGround typically contain:
|
|
- `wp-content/uploads/` — images, media (backup all)
|
|
- `wp-content/plugins/` — can reinstall, but backup for config preservation
|
|
- `wp-content/themes/` — custom themes, backup
|
|
- `wp-content/cache/` — OK to skip
|
|
- `error_log` — large debug logs, OK to skip
|
|
|
|
## Restore
|
|
|
|
1. Download tar.gz from S3
|
|
2. Extract on new host: `tar xzf <site>-<date>.tar.gz`
|
|
3. Set correct permissions: `chown -R www-data:www-data <site>/`
|
|
4. Import database from phpMyAdmin export or MySQL dump
|
|
5. Update `wp-config.php` with new DB credentials
|
|
6. Point DNS to new server
|
|
|
|
## Database
|
|
|
|
SFTP provides **files only**. The MySQL database must be exported separately:
|
|
- Via SiteGround's phpMyAdmin interface
|
|
- Or: `mysqldump -h <host> -u <user> -p <dbname> > <site>-db-<date>.sql`
|
|
- Upload the SQL dump to Core via SFTP/scp and store alongside the files
|
|
|
|
## Migration Strategy
|
|
|
|
1. SFTP backup all sites to S3 (done Jul 9, 2026)
|
|
2. Export each site's database from phpMyAdmin → upload to S3
|
|
3. On new box, restore files + import DB
|
|
4. Update wp-config.php credentials
|
|
5. Point DNS → done
|
|
|
|
No downtime per site if DNS is the last step.
|