Skip to main content

close1

A simple tool for daily backups of files and databases over SSH.

Features

  • Pulls files and directories (.tar.gz/.zip) from the servers to your machine; nothing is installed on the servers.
  • Runs commands on the servers (for example, mysqldump, .backup in sqlite3, or stopping a web server for the duration of the backup and starting it again afterwards).
  • Good SSH integration: uses your key through the SSH agent (even if it is passphrase-protected). ControlMaster for speed and for reliability on lossy networks.
  • Tolerates missed cron runs (e.g. when the computer was off). You can run close1 from cron every hour and it still makes one backup per day.
  • Careful rotation: you set how many backups to keep (say, 7). Rotation removes the oldest ones, but it will not delete a 10-day-old backup if there were no newer ones. Even in the worst case you still have some backups.

Install

pipx install close1

Usage

close1 --check                 # SSH agent, keys, host reachability (copies nothing)
close1                         # back up all hosts from the config
close1 blog -f -v              # only blog, overwrite today's backup, verbose
close1 log                     # show the log (-v: print its path first)
close1 status                  # hosts in storage: last backup, number of days (-v: sizes, file counts)

Config: -c path, otherwise the first one found of $CLOSE1_CONFIG, ~/.config/close1/close1.yml, /etc/close1.yml (no merging). See close1-example.yml (short) and close1-full-example.yml (every option explained). Log: ~/.local/state/close1/close1.log (root: /var/log/close1.log).

Config

_default:
  dest: ~/backups          # -> ~/backups/<host>/<YYYY-MM-DD>/
  keep: 7

blog:
  pre:
    - mysqldump blog | gzip > /tmp/blog-${DATE}.sql.gz
  files:
    # "name:" is optional, only if you want to set the local file name
    - blog.sql.gz: /tmp/blog-${DATE}.sql.gz
    - /var/www/blog/uploads
    - /etc/nginx/sites-enabled
  post:
    - rm /tmp/blog-${DATE}.sql.gz

"backup@bot:2222":
  files:
    - /opt/bot/config.yml
  stdout:
    packages.txt: dpkg -l

All options with explanations: close1-full-example.yml.

SQLite

Do not copy a live SQLite file (in WAL mode part of the data lives in -wal). Take a snapshot in pre and fetch it:

pre:
  - umask 077 && sqlite3 /opt/app/app.db ".backup /tmp/app-${DATE}.db" && gzip -f /tmp/app-${DATE}.db
files:
  - app.db.gz: /tmp/app-${DATE}.db.gz
post:
  - rm -f /tmp/app-${DATE}.db.gz

Unreliable connections

All commands to a host go through one SSH connection (ControlMaster), so a backup needs a single handshake. After a connection error (ssh exit code 255) close1 retries the connection check, file checks and downloads (retries times, retry_delay seconds apart). pre, post and stdout commands are not retried: after a dropped connection it is unknown whether they ran. If they fail, the backup fails and the next cron run starts it again.

cron and ssh-agent

close1 authenticates through ssh-agent. If SSH_AUTH_SOCK is not set (as under cron), it looks for the socket in /run/user/$UID/ (openssh_agent, ssh-agent.socket, gcr/ssh, keyring/ssh, gnupg/S.gpg-agent.ssh). ssh is always called with BatchMode=yes and ForwardAgent=no. While you are not logged in or the key is not loaded into the agent, the backup is skipped and retried on the next run.

By default the first agent that holds any key is used. If you have several agents (e.g. ssh-agent and gnome-keyring) with different keys, set ssh_key: SHA256:... (globally or per host): close1 then uses the agent that holds this key and passes it to ssh as IdentityAgent. If the key is in no agent, the host is skipped. close1 --check lists all agents with their key fingerprints. The key comment (user@host) is not used for matching: it is arbitrary text.

17 * * * * $HOME/.local/bin/close1

Only errors go to stderr (and so to cron mail); everything else goes to the log.

Metadata

Release files for close1 0.8.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for close1 0.8.2
File Size Uploaded Provenance Actions
close1-0.8.2.tar.gz 23.3 kB Without provenance Details for close1-0.8.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for close1 0.8.2
File Interpreter ABI Platform Actions
close1-0.8.2-py3-none-any.whl Python 3 none any Details for close1-0.8.2-py3-none-any.whl

Total release size: 42.3 kB

Release files / close1-0.8.2.tar.gz

Download URL close1-0.8.2.tar.gz
Size 23.3 kB
Tags Source
SHA-256 checksum
How to use checksums
34e0d270398e9b5e4e5bfcc2367d9e1f3c18646fff842230b8ea7d4577be5028
BLAKE2b-256 checksum
How to use checksums
15123a636b3f4ddfb6baa506474029b30414dc60eea88abed2e77700a1ef7849
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.8 {"installer":{"name":"uv","version":"0.10.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / close1-0.8.2-py3-none-any.whl

Download URL close1-0.8.2-py3-none-any.whl
Size 19.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6f058589c319c243fc0aff67c531562304aa58790619e3b91887af9a819d2685
BLAKE2b-256 checksum
How to use checksums
46d3da2081044eb07ad68e0f9dee35bf1f036ecd26fbee1a042f3e6cb0185635
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.8 {"installer":{"name":"uv","version":"0.10.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for close1 0.8.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page