Re: [Tails-dev] Add simple GUI to back up persistent volume …

Delete this message

Reply to this message
Autore: David A. Wheeler
Data:  
To: intrigeri
CC: tails-dev
Oggetto: Re: [Tails-dev] Add simple GUI to back up persistent volume (attached)
On Aug 2, 2021, at 3:12 AM, intrigeri <intrigeri@???> wrote:

>: If I understood correctly, the data is copied to another, pre-existing
> (and already unlocked & mounted) Tails Persistent Storage, i.e.
> the scripts add a GUI on top of our current command line instructions:
> https://tails.boum.org/doc/first_steps/persistence/backup/


That’s correct, it simply creates a GUI for the existing instructions.
For many users, that’s a big improvement. No opening a terminal window,
and no typing or copying a long command string.

> The good news is that this is entirely compatible with the design we
> want to implement eventually (possibly next year).


Great!

> To me this would be a good incremental improvement over our current
> instructions.


Thank you, that’s my hope as well.

One small tweak: At one time my tails-backup script wrote to a log file, and there are a
few vestiges of that in what I posted. You should remove the lines that say:
    LOG="$HOME/backup-log.txt”
and
       rm -fr "${LOG}"


To make things easier for you,
below is a tweaked version of tails-backup that removes those lines.
The file tails-backup.desktop is unchanged from what I posted earlier, but
for simplicity I’m reposting it below (so it’s all in one place).

Again, it’s short & simple, it should be easy to review.

--- David A. Wheeler


==== tails-backup.desktop ====
[Desktop Entry]
Type=Application
Name=Backup persistent volume
Comment=Backup the Tails persistent volume to another TailsData volume
Exec=gnome-/usr/bin/gnome-terminal --title 'Log for Backing up Tails persistent volume' --hide-menubar -- /home/amnesia/Persistent/tails-backup
Terminal=false
Categories=Utilities
StartupNotify=false
#
# Test with:
# xdg-desktop-menu install tails-backup.desktop

==== tails-backup ====
#!/bin/sh
# tails-backup: Back up Tails' persistent disk into the mounted backup region.
# Persistent storage & backup storage must already be unlocked, and
# there must be an admin password set

set -eu

export TEXTDOMAIN='tails'

SOURCE='/live/persistence/TailsData_unlocked/'
DEST='/media/amnesia/TailsData/'

# Newline
NL="$(printf '\nX')"
NL="${NL%X}"

if [ ! -d "$SOURCE" ]; then
       msg="$(gettext -s 'Encrypted persistent storage must be unlocked first.  Please reboot, then unlock encrypted persistent storage and under additional settings set an administrative password.')"
       zenity --error --ellipsize --text "$msg"
       exit 1
fi


if [ ! -d "$DEST" ]; then
       msg="$(gettext -s 'Backup storage area must be unlocked first. Please run Applications ▸ Accessories ▸ Files, select the backup encrypted volume (TailsData), and unlock it with your passphrase.')"
       zenity --error --ellipsize --text "$msg"
       exit 1
fi


title="$(gettext -s 'Alert')"
msg="$(gettext -s 'Would you like to back up your persistent encrypted storage to the backup storage area? This will replace all data in the backup storage area.'"$NL"'If you agree, you will then need to enter your administrator password to actually run the backup.')"
if ! zenity --question --ellipsize --title "$title" --text "$msg"; then
       exit 1
fi


# Run real backup command. This requires privileges.
if pkexec /usr/bin/rsync -PaSHAXv --del "$SOURCE" "$DEST" ; then
       # Ensure RAM buffers are written out
       sync; sync; sync
       sleep 1
       msg="$(gettext -s 'Backup succeeded. Please eject (unmount) the backup storage area media.'"$NL"'You can do this by running Applications ▸ Accessories ▸ Files, selecting the backup encrypted volume (TailsData), and ejecting it.')"
       zenity --info --ellipsize --text "$msg"
else
       msg="$(gettext -s "Backup failed. See details in log file ${LOG}")"
       zenity --error --ellipsize --text "$msg"
       exit 1
fi