aboutsummaryrefslogtreecommitdiffstats
path: root/.local/bin/backup.sh
blob: 52ca53a1697547a43d46638c7780ecd8c9da25af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#! /bin/bash

backup_local(){
    # external program to supply the passphrase:
    export BORG_PASSCOMMAND="pass show $1" # repo pass first arg

    # Create Local Backups
    echo $( date ) "Creating Local Backups ..."
    REPOSITORY=$2 # repo vault path second arg
    shift 2 # consume the first 2 arguments
    borg create --list --filter AME --stats --compression=lz4 \
        --progress --exclude '*.pyc' \
        --exclude '*/.mypy_cache/' \
        --exclude '*/.notmuch' \
        --exclude '*/node_modules' \
        --exclude '*/js/compiled' \
        --exclude '*/mpd/log' \
        --exclude '*/venv/' \
        --exclude '*/.tox/' \
        --exclude '*.elc' \
        $REPOSITORY::'{hostname}-{user}-{utcnow:%Y-%m-%dT%H:%M:%S}' \
        $@ # all the dirs to bac

    # Prune Local Backups
    echo $( date ) "Pruning local repository ..."

    borg prune --verbose --stats --list \
        --prefix='{hostname}-{user}-' \
        --keep-daily 7 \
        --keep-weekly 4 \
        --keep-monthly 6 $REPOSITORY
}

backup_local borgbackup ssh://backup/media/Backup/daily_backup/ ~/dev/ ~/.mail/ ~/Nextcloud/ ~/org/ /media/backup/personal/Pictures/ /media/backup/personal/Libros/ /media/backup/personal/dev/ /media/backup/Archives/
backup_local Admin/sarah/borg/ingrid ssh://borgbackup@najera.pw/./repos/ingrid ~/dev/ ~/org/ ~/.mail/ ~/Nextcloud/
backup_local Admin/sarah/borg/oscar ssh://borgbackup@najera.pw/./repos/oscar  /media/backup/personal/Pictures/ /media/backup/personal/Libros/ /media/backup/personal/dev/ /media/backup/Archives/