Portabase Logo
Portabase AgentDatabases

Files

Back up a directory with Archive, Snapshots, Sync or Copy.

Requirements

The files type requires Agent 1.24.0+. The Copy method and the Sync delete limits require Agent 1.25.0+. You can add a source from the dashboard (Add database on the agent page), with the CLI, or in databases.json.

The files type backs up a directory that the agent can read: uploads, application data, configuration, a Nextcloud data folder, and so on. No database driver is involved: the agent reads the files directly, so the directory must be mounted in the agent container.

Choose a method

Each source uses one of four methods. The method is chosen when the source is created and cannot be changed afterwards: to switch, create a new source.

MethodmethodWhat each run storesRestore from PortabaseStorage growth
Archivearchive (default)A full tar.gz archive of the directory.YesFull size on every run
SnapshotssnapshotAn incremental, deduplicated restic snapshot. Only new and changed data is uploaded.YesNew data + restic metadata
SyncsyncA mirror of the directory on each storage, kept up to date with rclone.NoSize of the directory
CopycopyA copy of the directory on each storage, made with rclone copy: new and changed files are added, files deleted from the source are kept.NoEvery file ever copied
  • Archive is the simplest choice for small directories, and each backup is a self-contained file.
  • Snapshots suits large directories that change little: each run only uploads what changed, and every snapshot can be restored.
  • Sync keeps a browsable copy of the latest state on your storage. It is not a backup history.
  • Copy works like Sync but never deletes anything from the replica: a file removed from the source, by mistake or by an application that prunes its folder, stays on the storage.

Sync and Copy are not a history

With Sync, deletions and changes in the source are copied to the replica on the next run, including those caused by a mistake or by ransomware. Copy keeps deleted files, but a changed file is still overwritten: a file encrypted in place by ransomware replaces the good copy. Neither keeps older versions nor can be restored from Portabase. Pair them with an Archive or Snapshots source when you need history.

Configuration

On the agent page, click Add database, choose Files, then fill in:

  • Path: the directory inside the agent container (e.g. /data/uploads). It must be absolute and cannot be /.
  • Method: Archive, Snapshots, Sync or Copy. Locked once the source is created.
  • Exclude: one pattern per line (see Exclude patterns).
  • Stay on one file system: skip the mount points found inside the directory.
  • Max deletions per run and Max deleted size per run: shown for Sync only, see Sync delete limits.

The directory must still be mounted in the agent container.

Exclude patterns

  • A pattern without a leading / matches at any depth: node_modules excludes every node_modules folder.
  • A pattern with a leading / is relative to the source path: /cache only excludes <path>/cache.
  • * does not cross /; use ** to match across folders.
  • Brace alternation (*.{log,tmp}) is not supported by Snapshots: list each pattern separately (*.log, *.tmp).

Excluded paths are not backed up and are left untouched by a restore. With Sync, files that match a pattern are deleted from the replica on the next run; with Copy, files already copied stay on the replica.

Sync delete limits

A Sync run deletes from the replica every file that disappeared from the source. Two optional limits stop a run that would delete too much, for example after an application wiped its folder:

OptionDashboard fieldValue
max_deleteMax deletions per runA whole number. 0 allows no deletion at all.
max_delete_sizeMax deleted size per runA size such as 500M or 10G (B, K, M, G, T or P). A number without a suffix is in KiB.

When a limit is set, the agent first runs rclone sync --dry-run with the same settings. If the run would go over a limit, it fails before deleting anything, with the message sync would delete more than the limit (…); nothing was deleted, and the usual backup alerts are sent. Files removed by an exclude pattern count as deletions.

To accept a large deletion on purpose, clear the limit, run the sync, then set the limit back.

The dry run lists the source and the replica once more on every run, which adds requests on object storage. Leave both fields empty to keep a single pass. The limits can be changed at any time and are ignored by the other methods.

Mount the directory

The agent only sees the directories mounted in its container. Mount the directory read-write: restores write into it.

docker-compose.yml
services:
  agent:
    image: portabase/agent:latest
    volumes:
      - ./databases.json:/config/config.json
      # Host directory -> path used for the source
      - /srv/uploads:/data/uploads
    environment:
      TZ: "Europe/Paris"
      EDGE_KEY: "..."

With the CLI, this mount is generated for you.

Restore

Archive and Snapshots restores make the directory match the backup:

  1. The agent checks the backup first. A corrupt or truncated archive is rejected and nothing is changed.
  2. Files that are not in the backup are removed, except excluded paths.
  3. The backup content is written into the directory. When the agent runs as root, file ownership is restored too.

A restore deletes the files created since the backup. Add an exclude pattern for any subfolder that must survive a restore.

Sync and Copy sources cannot be restored from Portabase. The replica is a plain copy stored under <folder>/sync/<generated_id>/current on each storage (Copy uses the same layout): copy it back with your storage tools or rclone if needed. A Copy replica also holds the files deleted from the source, so copying it back brings them back too.

Good to know

  • Unreadable files fail the run. If a file cannot be read (permissions), an Archive or Snapshots run fails instead of producing a partial backup, because restoring it would delete that file. Fix the permissions or exclude the path.
  • Empty source. A Sync run refuses to start when the directory is empty, so an unmounted volume cannot wipe the replica. A Copy run cannot delete anything, so it runs and copies nothing.
  • Encryption. Archive backups are encrypted like any other backup when encryption is enabled, and can be decrypted with the CLI. Snapshots are always encrypted by restic, with a key derived from the agent key. The Sync and Copy replicas are stored as plain files.
  • Storages. Snapshots, Sync and Copy work with every storage provider. An Azure Blob storage needs an account key: connection strings that only hold a SAS token are not supported.
  • Disk space on the agent. Archive builds the archive in the agent's temp directory (TMPDIR, /tmp by default), so it needs about the size of the directory free there, as for Docker volumes. Snapshots, Sync and Copy upload directly; Snapshots keeps a restic cache in the agent data folder.
  • Retention. Snapshots follow the retention policy like other backups: removed backups are forgotten from the restic repository. Sync and Copy keep a single replica: retention only removes the run history, never files from the replica. A Copy replica only grows; deleting the source removes its replica from every storage.

Last updated on

On this page