mirror of
https://codeberg.org/postscriptum/snac2nex.git
synced 2026-03-31 13:15:27 +00:00
4.1 KiB
4.1 KiB
snac2nex
Convert Snac profiles to the Nex blog format. Useful as a mirroring tool for an existing fediverse instance or for migrating the data once.
Install
cargo install snac2nex
Usage
snac2nex -s /path/to/snac/storage -t /path/to/nex -u user1 -u user2
Options
-s, --source <SOURCE>
Path to the Snac2 profile directory
-t, --target <TARGET>
Target directory for public data export
-u, --user <USER>
Username(s) to export
-a, --attachment <ATTACHMENT>
Include attachment files export
Supported values:
* `c` (`copy`) - copy files
* `h` (`hard`) - create hard links
* `s` (`soft`) - create soft links (macos, linux, windows only)
-r, --rotate <ROTATE>
Keep running as the daemon, renew every `n` seconds
-f, --format-content <FORMAT_CONTENT>
Post template pattern
[default: {content}{attachments}{link}{tags}{updated}]
--format-filename <FORMAT_FILENAME>
Post filenames format
* escaped with `%%`
[default: %H:%M:%S]
--format-updated <FORMAT_UPDATED>
Post `{updated}` time format
* escaped with `%%`
[default: "%Y/%m/%d %H:%M:%S"]
-k, --keep
Keep Nex entry on Snac post was removed
-d, --daemon
Disables some debug output
-h, --help
Print help (see a summary with '-h')
-V, --version
Print version
Systemd
To use snac2nex as the systemd service, install binary to the canonical system location:
git clone https://codeberg.org/postscriptum/snac2nex.git && cd snac2nexcargo build --releasesudo install target/release/snac2nex /usr/local/bin/snac2nex- tip: now you may want to clean the
snac2nexsources folder to free up disk space
- tip: now you may want to clean the
Setup shared access permissions:
useradd -m snac2nex- create new user with home dir (for log files)usermod -aG snac snac2nex- replacesnacwith thesystemdgroup for your Snac server
chmod -R g+r /path/to/snac/storage- give the group read permissions to Snac directories
usermod -aG nexy snac2nex- replacenexywith thesystemdgroup for your your Nex protocol server (e.g. Nexy)
chmod -R g+rw /path/to/nex- give the group read/write permissions to Nex directories
Create new systemd configuration file /etc/systemd/system/snac2nex.service:
[Unit]
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
User=snac2nex
Group=snac2nex
# Uncomment if your Snac or Nex unit has ExecStartPre timeout option
# ExecStartPre=/bin/sleep 15
ExecStart=/usr/local/bin/snac2nex -s /path/to/snac/storage -t /path/to/nex -u user1 -u user2 -r 3600 -d
StandardOutput=file:/home/snac2nex/debug.log
StandardError=file:/home/snac2nex/error.log
[Install]
WantedBy=multi-user.target
- replace
ExecStartarguments with your values, where:-s- Snacstoragelocation-u- Snacuser(s) to sync-t- Nex servertargetlocation for public files-r- isrotateevery hour (3600seconds) to apply Snac instance updates (instead of export once)-d- enabledaemonmode, which disables some debug output, to prevent extra write operations- optionally, include
-a(attachment) asc(copy) |h(hardlink) |s(softlink)
systemctl daemon-reload- apply newsystemdconfigurationsystemctl enable snac2nex- auto-startsnac2nexsync on system bootsystemctl start snac2nex- startsnac2nexsync now