7.8 KiB
Nstarikov Storage Migration Implementation Plan
For agentic workers: REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (
- [ ]) syntax for tracking.
Goal: Relocate non-latency-sensitive persistent files from the root disk to the mounted 100 GB storage volume, retain Directus backups predictably, and preserve service paths.
Architecture: Use /var/www/dzen.nstarikov.ru/storage as the single storage root. Copy online first; stop only the relevant process for a final rsync --delete; preserve the former path as a symlink or explicit Compose bind mount. Keep timestamped rollback directories until every post-check passes.
Tech Stack: ext4, rsync, Docker Compose, gzip, shell, Caddy.
Task 1: Validate storage and create isolated target directories
Files:
-
Modify:
/etc/fstabonly if the existing storage mount is not persistent; otherwise no config change. -
Step 1: Confirm the mounted volume and free capacity
Run:
findmnt -no SOURCE,TARGET /var/www/dzen.nstarikov.ru/storage && df -h / /var/www/dzen.nstarikov.ru/storageExpected: the storage target is on its own filesystem with at least 80 GB free.
-
Step 2: Create only named category directories
Run:
install -d -m 0755 /var/www/dzen.nstarikov.ru/storage/{directus-backup,geopolitics-story-temp,vk2ok-storage,dzen-media,n8n-archive,caddy-logs}Expected: all target directories exist on the storage filesystem; nothing is stored directly in the videos directory.
Task 2: Migrate Directus dumps and apply explicit retention
Files:
-
Modify:
/var/www/api.nstarikov.ru/backup/backup.sh -
Move:
/var/www/api.nstarikov.ru/backupto/var/www/dzen.nstarikov.ru/storage/directus-backup -
Step 1: Back up the backup script and add deterministic retention
Retain the latest
directus_*.sql.gzfrom every one of the latest 14 calendar days. For files older than those days, retain the latest file from each of the three newest ISO weeks. Delete all other matching dumps only after a successful dump and gzip integrity check. Do not deletebackup.shor non-matching files. -
Step 2: Make an online copy and record a manifest
Run:
rsync -aHAX --info=progress2 /var/www/api.nstarikov.ru/backup/ /var/www/dzen.nstarikov.ru/storage/directus-backup/ && (cd /var/www/dzen.nstarikov.ru/storage/directus-backup && sha256sum directus_*.sql.gz > .migration-sha256)Expected: destination contains every source dump and a checksum manifest.
-
Step 3: Stop only the dump writer, final-sync, and switch compatibility path
Run from
/var/www/api.nstarikov.ru:docker compose stop backup-pg; runrsync -aHAX --delete; rename source tobackup.pre-storage-YYYYmmddHHMMSS; createbackup -> /var/www/dzen.nstarikov.ru/storage/directus-backup; thendocker compose up -d backup-pg.Expected:
backup-pgis running and/backupresolves to the storage filesystem. -
Step 4: Verify data and retention contract
Run:
sha256sum -c .migration-sha256,gzip -t directus_*.sql.gz, inspect the nextbackup-pglog, and count selected daily/weekly files after retention logic runs.Expected: all pre-migration dumps validate; future runs keep 14 daily plus 3 older weekly dumps.
Task 3: Migrate bot media without changing application paths
Files:
-
Move:
/var/www/bots/geopolitics_tg_story/temp_videostostorage/geopolitics-story-temp -
Move:
/var/www/bots/vk2ok/storagetostorage/vk2ok-storage -
Step 1: Copy both sources online
Run
rsync -aHAX --info=progress2for each source into its named target directory.Expected: target file counts and byte totals match their sources before cutover.
-
Step 2: Cut over geopolitics temporary-video storage
Stop
geopolitics_story_app, final-sync with--delete, rename the old source with a timestamp, create a symlink attemp_videos, then start the container.Expected: the bot resumes and new writes follow the symlink onto storage.
-
Step 3: Cut over vk2ok storage
From
/var/www/bots/vk2ok, stopapi,worker, andbeat; final-sync with--delete; rename the old source with a timestamp; create thestoragesymlink; start the three services.Expected: API, worker, and beat are healthy and all storage paths resolve to the target filesystem.
Task 4: Migrate Dzen media using Compose mounts
Files:
-
Modify:
/var/www/dzen.nstarikov.ru/docker-compose.yml -
Move:
/var/www/dzen.nstarikov.ru/data/mediatostorage/dzen-media -
Step 1: Copy current media and prepare the explicit mount
Copy
data/media/tostorage/dzen-media/. Add/var/www/dzen.nstarikov.ru/storage/dzen-media:/app/data/mediato API, worker, and beat while keeping the existing data and videos mounts unchanged. -
Step 2: Recreate only Dzen API, worker, and beat
Stop those three services, run a final
rsync -aHAX --delete, rename the old media directory to a timestamped rollback name, then recreate the three services with the changed Compose file.Expected: uploads and generated media resolve from the new bind mount; Redis remains untouched.
-
Step 3: Verify Dzen application health and a known media response
Run the existing health endpoint and an HTTP request to one existing media asset.
Expected: health is successful and the media asset returns its expected content type and successful status.
Task 5: Move inactive n8n archive
Files:
-
Move:
/var/www/n8n.nstarikov.ru/archivetostorage/n8n-archive -
Step 1: Confirm no active Compose service consumes
archiveRun
docker compose psfrom/var/www/n8n.nstarikov.ruand inspect mounts for active n8n containers.Expected: no active container uses the archival directory.
-
Step 2: Copy, validate, and switch the compatibility path
Use rsync, compare file counts and byte totals, rename source to a timestamped rollback directory, and create
archive -> /var/www/dzen.nstarikov.ru/storage/n8n-archive.Expected: no application downtime and the archive path resolves to storage.
Task 6: Migrate Caddy logs last and prove external reachability
Files:
-
Modify:
/var/www/caddy/docker-compose.ymlor the equivalent active Compose file -
Move:
/var/www/caddy/logstostorage/caddy-logs -
Step 1: Inspect the active Caddy logging policy before alteration
Read Caddy log blocks and preserve their existing rolling/retention settings. Do not add generic logrotate or use
copytruncate. -
Step 2: Copy and switch the single Caddy log bind mount
Perform online rsync, stop/recreate Caddy for a final rsync and an updated log-source bind mount (or an equivalent parent-level compatibility symlink). Preserve the old directory as a rollback name.
Expected: only a brief proxy interruption; new log writes appear under
storage/caddy-logs. -
Step 3: Verify Caddy and public hosts
Check container health/logs, request
https://nstarikov.ru/,https://api.nstarikov.ru/, andhttps://dzen.nstarikov.ru/, and confirm each response is successful.
Task 7: Final accounting and deferred cleanup
Files:
-
No source-code changes.
-
Step 1: Verify every migration target and service
Run
df -h / /var/www/dzen.nstarikov.ru/storage;findmnt;readlink -ffor every compatibility path; and targeted Docker health/log checks.Expected: root usage has decreased by the moved data size, targets live on storage, and all affected services are healthy.
-
Step 2: Retain rollback sources until explicit cleanup approval
Keep every timestamped
*.pre-storage-*directory untouched after verification. Report their paths and sizes. Do not remove them in this migration because removal is destructive and needs a final explicit decision.