Diff for "TechDocs/OfficeBackUp/Script"

Differences between revisions 3 and 4
Revision 3 as of 2019-02-12 13:41:47
Size: 2440
Editor: max.mehl
Comment: change paths
Revision 4 as of 2019-02-12 13:48:27
Size: 2446
Editor: max.mehl
Comment: fix shebang
Deletions are marked like this. Additions are marked like this.
Line 22: Line 22:
{{{ {{{#!sh

Script for Office Backups

This script makes backing up data semi-automatically quite simple, following the Office Backup guide.

Save the script

  1. Save the code below (in the gre box) to a directory of your choice, for example as a new file called borg_backup.sh in a directory bin inside of your home directory.

  2. Open the directory, in which you created this file, with your terminal. Now execute chmod +x borg_backup.sh to make the file executable.

Configure the script

Now, open the file in a plain text editor and change some parts:

  • Change the value behind export BORG_REPO= to the actual destination you save your backups in. Please consult the people maintaining the backups in the office for assistance.

  • If wished, edit the value behind BACKUP=. Here, we save almost everything within your home directory.

  • If you derived your pass settings from the guide mentioned above, edit the value behind export BORG_PASSCOMMAND= to set the pass entry you used for borg's password.

  • By default, this script excludes the .cache directory in your home folder which does not contain valuable information. If you want to exclude more, for example large downloads or git repositories, copy the line containing --exclude $HOME/.cache and adapt the path.

  • The last command takes care of pruning old backups following a well-established scheme. You may edit it if you want, but please consult the borg documentation first.

#!/bin/sh

# Destination for borg repository
export BORG_REPO=ssh://FSFEUSER@fsfe-backup.fritz.box:22/~/Borg

# Which files/directories shall be backupped? Separate with spaces
BACKUP="$HOME"

# command to get borg password from, in this case from within `pass`
export BORG_PASSCOMMAND='pass show borg_backup'

# Actual backup command
# If you need to exclude more directories, copy and amend `--exclude` line
borg create --verbose --stats --progress \
            --one-file-system --compression lz4 --exclude-caches \
            --exclude $HOME/.cache    \
            ::'{hostname}-{now}'      \
            ${BACKUP}


borg prune -v --list            \
              --keep-within=1d  \
              --keep-daily=7    \
              --keep-weekly=4   \
              --keep-monthly=12 \
              --prefix '{hostname}-'

TechDocs/OfficeBackUp/Script (last edited 2019-02-12 13:48:27 by max.mehl)