dls_backup_bl
Back up the configuration of the devices on a Diamond beamline — PMAC and GeoBrick motor controllers, Moxa and ACS terminal servers, and Zebra boxes — into a git repository.
Each run fetches every device listed for the beamline, writes the results into
the beamline's backup area and commits anything that changed. Because the area
is a git repository you get two things a pile of files cannot give you: a device
can be restored after a failure, and git log tells you when a working
configuration last changed and how.
| What | Where |
|---|---|
| Source | https://github.com/DiamondLightSource/dls-backup-bl |
| PyPI | pip install dls-backup-bl |
| Docker | docker run ghcr.io/diamondlightsource/dls-backup-bl:latest |
| Releases | https://github.com/DiamondLightSource/dls-backup-bl/releases |
Quick start
Run it from a workstation on the beamline you are backing up, and pass nothing but your email address:
dls-backup-bl --email you@diamond.ac.uk
Everything else is derived from the $BEAMLINE environment variable, so on a
beamline workstation there is nothing else to configure. A report is emailed
when the run finishes, and printed as a summary at the end either way.
To check where it is about to write before you run it:
dls-backup-bl --folder
What gets backed up
| Device | How it is fetched | What lands in the backup area |
|---|---|---|
| PMAC / GeoBrick | telnet, directly or through a terminal server port | MotionControllers/<controller>.pmc |
| Moxa NPort terminal server | HTTP(S) to the device's web UI | TerminalServers/<address>_config.dec (and/or .ini, see below) |
| ACS terminal server | scp of the device's flash config |
TerminalServers/<address>_config.tar.gz |
| Zebra | EPICS Channel Access — the IOC writes its own file | Zebras/<name> |
Devices are backed up in parallel (--threads, default 10) and each one is
retried on failure (--retries, default 4).
Where the backups go
The default backup area is /dls_sw/work/motion/Backups/<BLXXY>, where BLXXY
comes from $BEAMLINE: i16 becomes BL16I, and a branch line such as i09-1
becomes BL09J. Override the beamline with --beamline i16, the whole
directory with --dir, or — where a BLXXY name makes no sense — the folder
name alone with --domain ME01D.
/dls_sw/work/motion/Backups/BL16I/
├── BL16I-backup.json the list of devices to back up
├── MotionControllers/ <controller>.pmc, plus <controller>_positions.pmc
├── TerminalServers/
├── Zebras/
├── backup.log the summary that is committed and emailed
└── backup_detail.log full debug log of the most recent run only
backup.log is the record of what succeeded and failed; it is committed with
the backup and is the text that --email sends. backup_detail.log is never
committed and is overwritten every run, so it only ever describes the run that
just happened — check it first when diagnosing a failure.
Choosing which devices are backed up
The device list lives in <backup area>/<BLXXY>-backup.json. Edit it with the
GUI:
dls-backup-gui
or by hand — it is plain JSON:
{
"motion_controllers": [
{
"controller": "BL16I-MO-BRICK-01",
"port": 1025,
"server": "172.23.240.97"
}
],
"terminal_servers": [
{
"server": "bl16i-nt-tserv-01",
"ts_type": "moxa",
"decrypt": true
}
],
"zebras": [
{ "Name": "BL16I-EA-ZEBRA-01" }
]
}
ts_type is one of moxa, acs or acsold. decrypt asks for that Moxa's
backup to be saved as a readable .ini instead of an encrypted .dec; it
defaults to false, is ignored for ACS servers, and is overridden for the whole
run by --decrypt / --decrypt-only. A motion controller with
"port": 1025 is contacted directly; any other port means it is reached through
a terminal server. An existing dls-pmac-analyse configuration can be imported
instead of typing the controllers in:
dls-backup-bl --import-cfg /path/to/pmac-analyse.cfg
To back up only some of the listed devices, name them:
dls-backup-bl --devices BL16I-MO-BRICK-01 BL16I-MO-BRICK-02
Motor positions
Motor positions change constantly, so they are kept out of the ordinary backup
commit and handled explicitly with --positions:
dls-backup-bl --positions save # record current positions and commit them
dls-backup-bl --positions compare # report how positions have moved since
dls-backup-bl --positions restore # write the last committed positions back
compare writes its report to positions_comparison.txt in the backup area and
commits it, so there is a record of what was checked and when.
Reading a Moxa terminal server backup
An NPort exports its configuration encrypted, so a .dec file cannot be read or
diffed without putting it back on a device. This tool can decrypt them locally,
with no device and no vendor software.
Set decrypt on a terminal server in the configuration file to have its backup
saved as an .ini from then on, or ask for it a run at a time:
dls-backup-bl --decrypt # write both .dec and a readable .ini
dls-backup-bl --decrypt-only # write only the .ini
The encrypted export is only dropped once a readable copy has been written, so a wrong pre-shared key can never cost you the backup.
Or convert a backup you already have, without running a backup at all:
dls-backup-bl --decrypt-file BL16I/TerminalServers/172.23.243.10_config.dec
# writes 172.23.243.10_config.ini
dls-backup-bl --decrypt-file 172.23.243.10_config.dec --out - # to stdout
which makes the configurations greppable and diffable:
dls-backup-bl --decrypt-file a_config.dec --out - | grep -i '^Server Name'
diff <(dls-backup-bl --decrypt-file a_config.dec --out -) \
<(dls-backup-bl --decrypt-file b_config.dec --out -)
The .ini is the device's own format: it can be edited and uploaded straight
back to an NPort through its web UI. Output keeps the device's CRLF line
endings, so add | tr -d '\r' if that gets in the way of a text tool.
Decryption uses the configuration pre-shared key, which devices leave at the
factory default moxa. If a device has been given its own key, pass it with
--psk. A wrong key is caught by the file's checksum rather than silently
producing rubbish.
Common options
| Option | Purpose |
|---|---|
-e, --email ADDRESS |
email the backup report |
-b, --beamline i16 |
back up a beamline other than $BEAMLINE |
--dir DIR |
use a different backup area |
-d, --devices NAME ... |
back up only the named devices |
-p, --positions save|restore|compare |
handle motor positions |
--folder |
print the backup folder and exit |
-l, --log-level debug |
more detail on the console |
dls-backup-bl --help lists every option.
Development
git clone https://github.com/DiamondLightSource/dls-backup-bl.git
cd dls-backup-bl
tox -p # pre-commit, mypy and the tests
The tests are self-contained and need no beamline, device or network. The
exception is tests/test_nport_estate.py, which checks that every terminal
server backup we hold still decrypts. Those are live configurations and cannot
be committed here, so it skips unless you point it at them — see its docstring.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dls_backup_bl-1.3.1.tar.gz.
File metadata
- Download URL: dls_backup_bl-1.3.1.tar.gz
- Upload date:
- Size: 210.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4c51d3c388117e592e8ba497d3da232fff280c64ea3c6fd3b5c30e80a8d7ef82
|
|
| MD5 |
15c85e7f4c4400a4dc6da780972e4a7c
|
|
| BLAKE2b-256 |
47fd2d8c0528a544e3a92669a1d3d18eeb19b53994870cb377e6a875fd94ffc3
|
File details
Details for the file dls_backup_bl-1.3.1-py3-none-any.whl.
File metadata
- Download URL: dls_backup_bl-1.3.1-py3-none-any.whl
- Upload date:
- Size: 45.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
befe7db72711300828a186d8a9c45d3218ecd5717a67aa9d6bd89b4d566a115c
|
|
| MD5 |
d710f3242ce2410348b26268d250ac3e
|
|
| BLAKE2b-256 |
966ab0250a62bf41d085cc85933211e83b9defe0b1184a21dc4b61f43cff2f75
|