Debian: Off-Site-Backup über GoCryptFS nach Jottacloud
Fehler, Verbesserungen oder Anmerkungen können mir gern per Email geschickt werden.
Vorraussetzungen
- Verständnis von Dateistrukturen.
- Vorstellung wo wie welche Daten (lokal, On-Site, Off-Site, Cloud/Auftragsdatenverarbeitung) verarbeitet werden können.
tl;dr
Installation auf dem System:
- Installation von GoCryptFS
- Setup von GoCryptFS
- Subscription bei Jottacloud
- Installation von Jottacloud
- Setup von Jottacloud-Sync
Test auf Zweitsystem:
- Installation von GoCryptFS
- Setup von GoCryptFS
- Installation von Jottacloud
- Setup von Jottacloud-Sync
- Check auf Gleichheit
- z.B. mit rsync sollten keine zu synchronisierenden Dateien gefunden werden.
rsync --recursive --times --links --perms --verbose --progress --stats --delete -e ssh /local/dir/path/ user@example.net:/server/dir/path/ --dry-runrsync -rtlpv --progress --stats --delete -e ssh /local/dir/path/ user@example.net:/target/dir/path/ --dry-runrsync -rtlpv --progress --stats --delete /source/dir/ /target/dir/ --dry-run
Ergebnis:
Verzeichnisse sind relativ für die Nutzer.
/home/${APPUSER}(Home)/home/${APPUSER}/.config/gocryptfs(GoCryptFS-Konfigurationsverzeichnis)/home/${APPUSER}/.config/gocryptfs/${APPUSER}.config(Konfiguration für das GoCryptFS-Verzeichnis des Nutzers)/home/${APPUSER}/.config/gocryptfs/${APPUSER}.pwd(Passwort für das GoCryptFS-Verzeichnis)/etc/systemd/system/gocryptfs@.service(GoCryptFS-Service welche mit obigem Setup funktioniert:# systemctl enable gocryptfs@${APPUSER}.service)/media/storage/${APPUSER}(Verzeichnis mit den unverschlüsselten Daten)/media/storage/${APPUSER}.gcfs(Virtuelles Verzeichnis mit den verschlüsselten Daten)/home/${APPUSER}/.config/jotta(Jottacloud-Konfigurationsverzeichnis)/etc/systemd/system/jottad@.service(Jottacloud-Service welche mit obigem Setup funktioniert:# systemctl enable jottad@${APPUSER}.service)- Service ist vonn GoCryptFS-Service abhängig.
Setup
GoCryptFS
Installation
apt install gocryptfsSetup des Nutzer-Verzeichnisses zur Verschlüsselung
# Vars
APPUSER=frank
DIRNAME=${APPUSER}
CIPHERPATH=/media/storage/${DIRNAME}.gcfs
PLAINPATH=/media/storage/${DIRNAME}
DIRPWDFILE=/home/${APPUSER}/.config/gocryptfs/${DIRNAME}.pwd
touch ${DIRPWDFILE}
chmod 600 ${DIRPWDFILE}
# Dirs
mkdir -p ~/.config/gocryptfs/ ${CIPHERPATH} ${PLAINPATH}
chmod 700 ~/.config/gocryptfs/
# Init
gocryptfs -init -config ~/.config/gocryptfs/${DIRNAME}.conf -reverse ${DIRNAME}
gocryptfs -init -config ~/.config/gocryptfs/${DIRNAME}.conf -reverse ${PLAINPATH}
# Mount
gocryptfs -config ~/.config/gocryptfs/${DIRNAME}.conf -reverse ${PLAINPATH} ${CIPHERPATH}
#cd ${CIPHERPATH} && gocryptfs -reverse ${DIRNAME} ${PLAINPATH}
# Umount
fusermount -u ${CIPHERPATH}
# Change pwd
gocryptfs -config ~/.config/gocryptfs/${DIRNAME}.conf -passwd ${CIPHERPATH}WICHTIG: Erstelle ein separates Backup der Datei ~/.config/gocryptfs/${DIRNAME}.conf. Das wird für das Recovery benötigt.
Setup des System-Service für den Nutzer
Nun erstellen wir einen Service, welcher die virtuelle Verschlüsselung bereit stellt, damit beim Booten automatisch dieser und die Cloud-Synchronisation starten kann.
APPUSER=frank
cat > /etc/systemd/system/gocryptfs@.service <<__EOF__
[Unit]
Description=Reverse mount of a folder into a gocryptfs-encryption for %i
ConditionPathIsDirectory=/media/storage/%i
ConditionPathIsDirectory=/media/storage/%i.gcfs
ConditionPathExists=/home/%i/.config/gocryptfs/%i.pwd
[Service]
Type=oneshot
User=%i
RemainAfterExit=yes
ExecStart=gocryptfs -config /home/%i/.config/gocryptfs/%i.conf -passfile /home/%i/.config/gocryptfs/%i.pwd -reverse /media/storage/%i /media/storage/%i.gcfs
ExecStartPre=mkdir -p /media/storage/%i.gcfs
ExecStop=fusermount -u /media/storage/%i.gcfs
[Install]
WantedBy=multi-user.target
__EOF__
systemctl enable gocryptfs@${APPUSER}
systemctl start gocryptfs@${APPUSER}
systemctl status gocryptfs@${APPUSER}Jottacloud
Subscription
- Account erstellen.
- 5 GB sind kostenlos.
- Ideal zum Testen des Setups.
- Einloggen.
- In den Einstellungen ein Login-Token für das Command-Line-Tool generieren.
- Bei gefallen empfiehlt sich: Jottacloud Personal [1] für € 7,99/Monat oder € 79,90/Jahr. → Limitierte Bandbreite ab der Nutzung von mehr als 5 TB.
Installation
apt install wget apt-transport-https ca-certificates
curl https://repo.jotta.us/public.gpg | gpg --dearmor > /usr/share/keyrings/apt-jottacloud-key.gpg
echo "deb [signed-by=/usr/share/keyrings/apt-jottacloud-key.gpg] https://repo.jotta.us/debian debian main" | tee /etc/apt/sources.list.d/jottacloud.list
apt update
apt install jotta-cli
systemctl stop jottad
systemctl disable jottad
systemctl status jottadSetup des System-Service für den Nutzer
cat > /etc/systemd/system/jottad@.service <<__EOF__
[Unit]
Description=Jottacloud cli for %i
After=network.target
Requires=gocryptfs@%i.service
[Service]
Type=simple
User=%i
EnvironmentFile=-/etc/default/jottad
EnvironmentFile=-/etc/sysconfig/jottad
ExecStart=jottad datadir /home/%i/.config/jotta/
Restart=always
WorkingDirectory=/
[Install]
WantedBy=multi-user.target
__EOF__
APPUSER=frank
systemctl enable jottad@${APPUSER}
systemctl start jottad@${APPUSER}
systemctl status jottad@${APPUSER}“Starting with version 0.4.x jottad will be run as the user jottad.” [1]
Setup des Jotta-Dienstes für den Nutzer
jotta-cli status
jotta-cli help
jotta-cli config get
APPUSER=frank
jotta-cli login
jotta-cli status
jotta-cli add /media/storage/${APPUSER}.gcfs
jotta-cli statusRecovery
- Installation von GoCryptFS
- Installation von Jotta-CLI
- Setup des lokale Jotta-Service
- Login ins Jotta-Cloud-Webseite: Generieren des Login-Tokens
- Lokales Jotta-Login
- Download des Backups
- Download der GoCryptFS-Datei
- Entschlüsselung als GoCryptFS
APPUSER=frank
jotta-cli login
jotta-cli status
jotta-cli download Backup/${DeviceName}/${APPUSER}.gcfs ~/Downloads/.
mkdir -p ~/Downloads/${APPUSER}
# Decrypt with config
gocryptfs -config ~/.config/gocryptfs/${APPUSER}.conf ~/Downloads/${APPUSER}.gcfs ~/Downloads/${APPUSER}
# Decrypt with master key
gocryptfs -masterkey=stdin ~/Downloads/${APPUSER}.gcfs ~/Downloads/${APPUSER}Ich habe erhebliche Intergritäts-Probleme, wenn ich mit dem Master-Key entschlüssle. Ich rate daher sehr dazu, die Config gut und sicher zu hinterlegen.
Alternative Einstellungen
Setup des System-Service für den Nutzer
Für das Einrichten eines echten Nutzerdienstes basierend auf einem nicht unter /home liegenden Nutzerverzeichnis.
APPUSER=frank
APPUSERHOME=$(cat /etc/passwd | grep ${APPUSER} | cut -d ":" -f6)
cat > /etc/systemd/user/jottad-frank.service <<__EOF__
[Unit]
Description=Jottacloud cli for ${APPUSER}
After=network.target
Requires=gocryptfs@%i.service
[Service]
Type=simple
User=${APPUSER}
EnvironmentFile=-/etc/default/jottad
EnvironmentFile=-/etc/sysconfig/jottad
ExecStart=jottad datadir ${APPUSERHOME}/.config/jotta/
Restart=always
WorkingDirectory=/
[Install]
WantedBy=multi-user.target
__EOF__Quellen
- systemd
- gocryptfs
- https://nuetzlich.net/gocryptfs/
- https://nuetzlich.net/gocryptfs/comparison/
- https://nuetzlich.net/gocryptfs/reverse_mode_crypto/
- https://manpages.debian.org/buster/gocryptfs/gocryptfs.1.en.html
- https://packages.debian.org/de/buster/gocryptfs
- https://wiki.archlinux.org/index.php/Gocryptfs
- https://defuse.ca/audits/gocryptfs.htm
- https://github.com/rfjakob/gocryptfs/issues/90
- https://wiki.ubuntuusers.de/GoCryptFS/
- Jottacloud
- https://www.jottacloud.com/en/home/
- https://www.jottacloud.com/signup/personal
- http://docs.jottacloud.com/jottacloud-command-line-tool#installing-the-command-line-tool
- https://docs.jottacloud.com/en/articles/1436834-jottacloud-command-line-tool
- https://docs.jottacloud.com/en/articles/1436855-jottacloud-cli-for-linux-debian-packages
- https://rclone.org/jottacloud/
- https://pypi.org/project/jottalib/
- https://news.ycombinator.com/item?id=25373047