Skip to content

Development

DatuX edited this page Nov 13, 2026 · 17 revisions

This page is for you if you want to change zfs-autobackup, or run it directly from git.

Setting up virtual env

This is optional. You can also install the requirements globally.

psy@ws1:~/zfs_autobackup$ python3 -m venv backupdev
psy@ws1:~/zfs_autobackup$ source backupdev/bin/activate
(backupdev) psy@ws1:~/zfs_autobackup$ pip install -r requirements.txt

Running zfs_autobackup

Run the tools as Python modules:

(backupdev) psy@ws1:~/zfs_autobackup$ python -m zfs_autobackup.ZfsAutobackup --version
(backupdev) psy@ws1:~/zfs_autobackup$ python -m zfs_autobackup.ZfsAutoverify --version

Automated test suites

I use test-driven development. Usually I write the code and its tests together.

The tests use real ZFS commands. They make many temporary pools with loopback images in /tmp.

Running tests via docker

This is the easiest method. It tests against the ZFS kernel module of your system, with the Alpine ZFS userspace tools.

From the main repository:

./tests/run_tests_docker

To run only some tests, use the unittest -k option:

./tests/autorun_tests_docker -k test_thinner.TestThinner

Running directly (without docker)

This is more difficult:

  • The tests need root.
  • The tests need SSH to root@localhost. They make and install an SSH key if necessary.

Running the whole suite

This takes a few minutes. GitHub Actions also runs it for each commit.

(backupdev) root@ws1:/home/psy/zfs_autobackup# ./tests/run_tests

Running one test

(backupdev) root@ws1:/home/psy/zfs_autobackup# ./tests/run_test test_verify.py

Running directly from pycharm

Method 1, remote via ssh:

This needs PyCharm Professional, but it is the easiest method. PyCharm uploads the tests and runs them on a remote Linux server via SSH. This is also good if you develop on macOS or Windows.

Add an SSH interpreter for a remote server with ZFS.

Method 2, locally:

The tests must run as root, but you want to start them from the editor. To do this:

  1. Make a venv.

  2. Replace the python symlink in the venv with a copy of the binary.

  3. Make the copy setuid root:

    user@host:~/zfs_autobackup/venv/bin$ sudo chown root:root python
    user@host:~/zfs_autobackup/venv/bin$ sudo chmod 4755 python

Warning: This is a security risk. Do this only on a development system.

Clone this wiki locally