Skip to content

Instantly share code, notes, and snippets.

@ErikFontanel
Last active February 7, 2026 10:07
Show Gist options
  • Select an option

  • Save ErikFontanel/17e9c02a094063099fdf7921bab06d3a to your computer and use it in GitHub Desktop.

Select an option

Save ErikFontanel/17e9c02a094063099fdf7921bab06d3a to your computer and use it in GitHub Desktop.
Jotta-cli on synology

Jotta-cli on Synology NAS

Setup

  1. Add jottad as a user and group in the web interface
  2. Download jotta-cli
  3. sudo tar -xf jotta-cli_xxx_linux_arm64.tar.gz
  4. sudo mv etc/jottad /etc/
  5. sudo mv usr/share/jottad /usr/share
  6. sudo mv usr/bin/jotta* /usr/bin
  7. sudo /usr/share/jottad/install.sh
  8. sudo chown -R jottad:jottad /var/lib/jottad/

Starting

Start with sudo systemctl start jottad

Stopping

Stop with sudo systemctl stop jottad

Usage

  • Limit jottad from eating up all resources:
    jotta-cli config set slowmomode 1
  • Add folders to watch:
    jotta-cli add /volume1/Erik/mbp.sparsebundle
  • Pause jotta-cli for 8h: jotta-cli pause 8h
  • View progress: jotta-cli observe

Automatic start/stop at midnight/morning

In the Synology web interface go to Control Panel -> Task Scheduler and add a task for user jottad and your user:

General Schedule Task Settings
Name: description Run on: Daily Run command:
User: jottad Time: 07:00 /bin/jotta-cli pause 17h
Name: Update Jotta-cli Run on: Monthly Run command:
User: you Time: 07:01 $HOME/update-jotta.sh
#!/bin/bash
# --- Configuration ---
REPO_URL="https://repo.jotta.us/archives/linux/arm64/"
LOG_FILE="/var/log/jotta-update.log"
BACKUP_DIR="/var/backups/jotta_$(date +%Y%m%d_%H%M%S)"
TMP_DIR="/tmp/jotta_update_$(date +%s)"
# Ensure script is run as root
if [ "$EUID" -ne 0 ]; then
echo "Error: Please run this script with sudo."
exit 1
fi
# Logging Function
log() {
local message="$(date '+%Y-%m-%d %H:%M:%S') - $1"
echo "$message"
echo "$message" >> "$LOG_FILE"
}
log "Starting Jotta update process..."
# --- Step 1: Find and Verify Latest Version ---
log "Fetching latest version info from $REPO_URL"
LATEST_TAR=$(curl -s "$REPO_URL" | grep -oE 'href="[^"]+\.tar\.gz"' | sed 's/href="//;s/"//' | sort -V | tail -n 1)
if [ -z "$LATEST_TAR" ]; then
log "ERROR: Could not find any .tar.gz files. Aborting."
exit 1
fi
mkdir -p "$TMP_DIR"
cd "$TMP_DIR" || exit
log "Downloading $LATEST_TAR and checksum..."
curl -L -O "${REPO_URL}${LATEST_TAR}"
curl -L -O "${REPO_URL}${LATEST_TAR}.sha256"
if sha256sum -c "${LATEST_TAR}.sha256" > /dev/null 2>&1; then
log "Checksum verified successfully."
else
log "ERROR: Checksum mismatch! Potential corruption. Aborting."
rm -rf "$TMP_DIR"
exit 1
fi
# --- Step 2: Create Rollback Backup ---
log "Creating backup for rollback in $BACKUP_DIR..."
mkdir -p "$BACKUP_DIR/bin" "$BACKUP_DIR/etc" "$BACKUP_DIR/share"
# Copy current files to backup location
[ -d "/etc/jottad" ] && cp -rp /etc/jottad "$BACKUP_DIR/etc/"
[ -d "/usr/share/jottad" ] && cp -rp /usr/share/jottad "$BACKUP_DIR/share/"
cp -p /usr/bin/jotta* "$BACKUP_DIR/bin/" 2>/dev/null
# --- Step 3: Perform Update ---
log "Stopping jottad service..."
systemctl stop jottad
log "Extracting and installing new files..."
tar -xf "$LATEST_TAR"
# Assume extraction creates ./etc and ./usr directories
if [ -d "./etc/jottad" ]; then
# Delete old files
rm -rf /etc/jottad /usr/share/jottad /usr/bin/jotta*
# Move new files in
mv ./etc/jottad /etc/
mv ./usr/share/jottad /usr/share/
mv ./usr/bin/jotta* /usr/bin/
chmod +x /usr/bin/jotta*
log "Starting jottad service..."
systemctl start jottad
# --- Step 4: Health Check & Rollback Logic ---
sleep 3 # Give it a moment to initialize
if systemctl is-active --quiet jottad; then
log "SUCCESS: Jotta updated to $(/usr/bin/jottad version 2>/dev/null || echo 'latest version') and is running."
# Keep backup for a while or remove it:
# rm -rf "$BACKUP_DIR"
else
log "CRITICAL: Service failed to start after update! Initiating Rollback..."
systemctl stop jottad
rm -rf /etc/jottad /usr/share/jottad /usr/bin/jotta*
# Restore from backup
mv "$BACKUP_DIR/etc/jottad" /etc/
mv "$BACKUP_DIR/share/jottad" /usr/share/
mv "$BACKUP_DIR/bin/jotta"* /usr/bin/
systemctl start jottad
log "ROLLBACK COMPLETE: Restored previous version. Check logs for service errors."
fi
else
log "ERROR: Extraction failed. Structure not as expected. Restarting old service."
systemctl start jottad
fi
# --- Step 5: Final Cleanup ---
rm -rf "$TMP_DIR"
log "Update script finished."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment