Persistent volumes
Every deploy starts your app in a fresh container, so anything it wrote to disk is gone. A volume is a directory that stays: a SQLite database, user uploads or a cache survive deploys, rollbacks, restarts and sleep.
Add one from the dashboard
Open the project's Settings
Under Volumes, choose Add volume.
Name it and pick where it mounts
For example data at /data. The path is where your app reads and writes, so point your database file or upload folder inside it.
Redeploy
The volume is mounted from the next deploy on. Its size shows next to it once it's in use.
Or in skiff.toml
Apps deployed with skiff deploy list their volumes in skiff.toml, up to five per app:
[[volumes]]
name = "data"
path = "/data"
[[volumes]]
name = "uploads"
path = "/app/public/uploads"Or from the terminal
skiff volume add shop-api data /data
skiff volume ls shop-api
skiff volume rm shop-api data --yesWhere they're mounted
- Every replica mounts the same volume, including ones added by autoscaling. Several replicas writing the same SQLite file at once can lock each other out, so keep a SQLite app at one replica.
- Workers, jobs and the release command see the same files, so a migration in the release command runs against the live database.
- Previews mount the same paths on empty volumes of their own. A preview never reads or changes production's files, and its volumes are deleted with it.
- Apps that don't run as root can write to a new volume. Skiff gives it to the user the image runs as, or the one set with
user:. A volume that already exists keeps its owner.
Sharing with another project
A project can mount a volume that another project in the team keeps, so both see the same files. It's how a model downloaded once is ready for every app that needs it, without downloading it again on each deploy or for each app.
Under Volumes in the project's settings, click Add volume and pick the other project's volume in the Volume menu, then choose where to mount it. Redeploy to mount it.
- The volume stays the other project's. Its budget, backups and disk are set there. Deleting it from the project that mounts it only stops that project using it; the files stay.
- It can't be deleted while another project uses it, and neither can the project that keeps it. Remove it from the others first. The volume's row says which projects use it.
- Moving it to another disk stops every project that uses it, and deploys each again afterwards.
- Previews of the project that mounts it get an empty volume of their own, as with any volume.
- Stacks share volumes among their own services in their compose file, so a stack's volumes aren't offered here.
Deleting
Deleting a volume from the dashboard removes its files on the next deploy, once no container uses it. Deleting a project deletes its volumes too. skiff down keeps them, so redeploying the same app picks its files back up.
Volumes are backed up daily and can be copied to an offsite bucket, so you can restore them from the project's Settings. See backups and encryption.
Budgets
A volume can have a size budget: click its size under Volumes in the project's settings and enter one in GB. Skiff checks every hour, and your alert channels hear once when the volume grows past its budget, and again if it shrinks back and grows past it later. A budget doesn't stop the app writing: it's a warning, so you can clear old files or move to a bigger disk in time.
On an added disk
When volumes or databases outgrow the server's own disk, add block storage from your provider and keep them there instead.
- Attach the storage and mount it, following your provider's guide, so it's a folder like
/mnt/datathat comes back after a restart (an entry in/etc/fstab). - On the Server page, under Disks, add it with a name and that folder. Only the server's admin can, and Skiff checks the folder really is on a different disk from the system's.
- A new volume can then keep its files on it (Keep its files on when you add the volume), and so can a new database (the disk menu when you create it). In
skiff.toml, setdisk = "/mnt/data"on a volume.
To move one that already exists, pick the disk in the menu on its row: Volumes on the project's Settings tab, or the database on the Databases page. Choose Server's disk to move it back. A move:
- Stops what uses it, so there's downtime for as long as the copy takes. An app is deployed again afterwards; a database starts again with the same address and password.
- Copies the files with their owners, permissions, timestamps and symlinks, and keeps the owner and mode of the volume's top folder. It then checks the copy has the same number of entries and the same total file size before removing the old ones. It doesn't compare file contents, and extended attributes, ACLs and hard links aren't kept. If the copy fails or doesn't match, the volume stays where it was and the app or database comes back on it.
- Tells your team's alerts if it fails.
The Server page shows each disk's free space. If a disk isn't mounted when the server starts, what's on it can't start until it's back. A disk can only be removed from the list once nothing is on it.
APIs and backends
A backend usually needs more than one public URL: internal services, a database, background work, and protection from too much traffic. Here's how those fit together on Skiff.
Debugging
Where to look when something is wrong: a deploy that failed, an app misbehaving, or data you need to check.