Borg Snapper Backup Configs & Scripts

This commit is contained in:
Sravan Balaji 2023-04-23 14:28:34 -04:00
parent fc26fc0600
commit 59d8130a78
6 changed files with 273 additions and 10 deletions

View File

@ -0,0 +1,60 @@
configs:
# MANDATORY: name of the snapper config
- name: root
# MANDATORY: borg repo target, e. g. backupuser@backuphost:reponame
repo: root@casaos:/media/casaos/12TB_HDD/Backups/oryp7/root
# if this is set to true, borg does not neccessarily fail when a backup fails
fault_tolerant_mode: true
# snapborg fails when the most recent snapshot transferred successfully is
# older than the time period given here. Set to '0d' to disable this behaviour
last_backup_max_age: 0d
# archive creation/storage options
storage:
# use either none or repokey encryption, defaults to none
encryption: none
# MANDATORY when using repokey: literal key passphrase or path to file
# containing the key passphrase. Ignored when using none encryption
encryption_passphrase: ~
# compression configuration, see borg manual
compression: auto,zstd,4
# define retention settings for borg independently from snapper
retention:
keep_last: 1
keep_hourly: 5
keep_daily: 7
keep_weekly: 0
keep_monthly: 0
keep_yearly: 0
# exclude patterns (see borg help patterns)
exclude_patterns: []
# MANDATORY: name of the snapper config
- name: home
# MANDATORY: borg repo target, e. g. backupuser@backuphost:reponame
repo: root@casaos:/media/casaos/12TB_HDD/Backups/oryp7/home
# if this is set to true, borg does not neccessarily fail when a backup fails
fault_tolerant_mode: true
# snapborg fails when the most recent snapshot transferred successfully is
# older than the time period given here. Set to '0d' to disable this behaviour
last_backup_max_age: 0d
# archive creation/storage options
storage:
# use either none or repokey encryption, defaults to none
encryption: none
# MANDATORY when using repokey: literal key passphrase or path to file
# containing the key passphrase. Ignored when using none encryption
encryption_passphrase: ~
# compression configuration, see borg manual
compression: auto,zstd,4
# define retention settings for borg independently from snapper
retention:
keep_last: 1
keep_hourly: 5
keep_daily: 7
keep_weekly: 0
keep_monthly: 0
keep_yearly: 0
# exclude patterns (see borg help patterns)
exclude_patterns: []

View File

@ -0,0 +1,60 @@
configs:
# MANDATORY: name of the snapper config
- name: root
# MANDATORY: borg repo target, e. g. backupuser@backuphost:reponame
repo: /run/media/sravan/5TB_HDD/Backups/oryp7/root
# if this is set to true, borg does not neccessarily fail when a backup fails
fault_tolerant_mode: true
# snapborg fails when the most recent snapshot transferred successfully is
# older than the time period given here. Set to '0d' to disable this behaviour
last_backup_max_age: 0d
# archive creation/storage options
storage:
# use either none or repokey encryption, defaults to none
encryption: none
# MANDATORY when using repokey: literal key passphrase or path to file
# containing the key passphrase. Ignored when using none encryption
encryption_passphrase: ~
# compression configuration, see borg manual
compression: auto,zstd,4
# define retention settings for borg independently from snapper
retention:
keep_last: 1
keep_hourly: 5
keep_daily: 7
keep_weekly: 0
keep_monthly: 0
keep_yearly: 0
# exclude patterns (see borg help patterns)
exclude_patterns: []
# MANDATORY: name of the snapper config
- name: home
# MANDATORY: borg repo target, e. g. backupuser@backuphost:reponame
repo: /run/media/sravan/5TB_HDD/Backups/oryp7/home
# if this is set to true, borg does not neccessarily fail when a backup fails
fault_tolerant_mode: true
# snapborg fails when the most recent snapshot transferred successfully is
# older than the time period given here. Set to '0d' to disable this behaviour
last_backup_max_age: 0d
# archive creation/storage options
storage:
# use either none or repokey encryption, defaults to none
encryption: none
# MANDATORY when using repokey: literal key passphrase or path to file
# containing the key passphrase. Ignored when using none encryption
encryption_passphrase: ~
# compression configuration, see borg manual
compression: auto,zstd,4
# define retention settings for borg independently from snapper
retention:
keep_last: 1
keep_hourly: 5
keep_daily: 7
keep_weekly: 0
keep_monthly: 0
keep_yearly: 0
# exclude patterns (see borg help patterns)
exclude_patterns: []

View File

@ -6,6 +6,7 @@ help_menu() {
rofi_menu() { rofi_menu() {
declare -a options=( declare -a options=(
" - backup-to-hdd" " - backup-to-hdd"
" - backup-to-casaos"
" Back - back" " Back - back"
" Quit - quit" " Quit - quit"
) )
@ -32,6 +33,9 @@ main() {
--backup-to-hdd) --backup-to-hdd)
kitty --hold /home/sravan/.scripts/backup_to_hdd.sh kitty --hold /home/sravan/.scripts/backup_to_hdd.sh
;; ;;
--backup-to-casaos)
kitty --hold /home/sravan/.scripts/backup_to_casaos.sh
;;
--rofi) --rofi)
rofi_menu rofi_menu
;; ;;

2
.scripts/backup_to_casaos.sh Executable file
View File

@ -0,0 +1,2 @@
#!/bin/bash
sudo snapborg --cfg /home/sravan/.config/snapborg/casaos_config.yaml backup

View File

@ -1,6 +1,2 @@
#!/bin/bash #!/bin/bash
sudo snap-sync \ sudo snapborg --cfg /home/sravan/.config/snapborg/hdd_config.yaml backup
--UUID fba0c463-99f4-41cf-8dc8-52a202a48849 \
--subvolid 5 \
--noconfirm \
--quiet

View File

@ -80,6 +80,7 @@
- [[#backups][Backups]] - [[#backups][Backups]]
- [[#rsync-options][Rsync Options]] - [[#rsync-options][Rsync Options]]
- [[#hdd][HDD]] - [[#hdd][HDD]]
- [[#casaos][CasaOS]]
- [[#rofi-menu][Rofi Menu]] - [[#rofi-menu][Rofi Menu]]
- [[#syncthing][Syncthing]] - [[#syncthing][Syncthing]]
- [[#user-programs][User Programs]] - [[#user-programs][User Programs]]
@ -7526,12 +7527,148 @@ inhibit_screensaver=1
*** HDD *** HDD
**** Script
#+BEGIN_SRC shell :shebang #!/bin/bash :tangle .scripts/backup_to_hdd.sh #+BEGIN_SRC shell :shebang #!/bin/bash :tangle .scripts/backup_to_hdd.sh
sudo snap-sync \ sudo snapborg --cfg /home/sravan/.config/snapborg/hdd_config.yaml backup
--UUID fba0c463-99f4-41cf-8dc8-52a202a48849 \ #+END_SRC
--subvolid 5 \
--noconfirm \ **** Configuration
--quiet
#+BEGIN_SRC yaml :tangle .config/snapborg/hdd_config.yaml
configs:
# MANDATORY: name of the snapper config
- name: root
# MANDATORY: borg repo target, e. g. backupuser@backuphost:reponame
repo: /run/media/sravan/5TB_HDD/Backups/oryp7/root
# if this is set to true, borg does not neccessarily fail when a backup fails
fault_tolerant_mode: true
# snapborg fails when the most recent snapshot transferred successfully is
# older than the time period given here. Set to '0d' to disable this behaviour
last_backup_max_age: 0d
# archive creation/storage options
storage:
# use either none or repokey encryption, defaults to none
encryption: none
# MANDATORY when using repokey: literal key passphrase or path to file
# containing the key passphrase. Ignored when using none encryption
encryption_passphrase: ~
# compression configuration, see borg manual
compression: auto,zstd,4
# define retention settings for borg independently from snapper
retention:
keep_last: 1
keep_hourly: 5
keep_daily: 7
keep_weekly: 0
keep_monthly: 0
keep_yearly: 0
# exclude patterns (see borg help patterns)
exclude_patterns: []
# MANDATORY: name of the snapper config
- name: home
# MANDATORY: borg repo target, e. g. backupuser@backuphost:reponame
repo: /run/media/sravan/5TB_HDD/Backups/oryp7/home
# if this is set to true, borg does not neccessarily fail when a backup fails
fault_tolerant_mode: true
# snapborg fails when the most recent snapshot transferred successfully is
# older than the time period given here. Set to '0d' to disable this behaviour
last_backup_max_age: 0d
# archive creation/storage options
storage:
# use either none or repokey encryption, defaults to none
encryption: none
# MANDATORY when using repokey: literal key passphrase or path to file
# containing the key passphrase. Ignored when using none encryption
encryption_passphrase: ~
# compression configuration, see borg manual
compression: auto,zstd,4
# define retention settings for borg independently from snapper
retention:
keep_last: 1
keep_hourly: 5
keep_daily: 7
keep_weekly: 0
keep_monthly: 0
keep_yearly: 0
# exclude patterns (see borg help patterns)
exclude_patterns: []
#+END_SRC
*** CasaOS
**** Script
#+BEGIN_SRC shell :shebang #!/bin/bash :tangle .scripts/backup_to_casaos.sh
sudo snapborg --cfg /home/sravan/.config/snapborg/casaos_config.yaml backup
#+END_SRC
**** Configuration
#+BEGIN_SRC yaml :tangle .config/snapborg/casaos_config.yaml
configs:
# MANDATORY: name of the snapper config
- name: root
# MANDATORY: borg repo target, e. g. backupuser@backuphost:reponame
repo: root@casaos:/media/casaos/12TB_HDD/Backups/oryp7/root
# if this is set to true, borg does not neccessarily fail when a backup fails
fault_tolerant_mode: true
# snapborg fails when the most recent snapshot transferred successfully is
# older than the time period given here. Set to '0d' to disable this behaviour
last_backup_max_age: 0d
# archive creation/storage options
storage:
# use either none or repokey encryption, defaults to none
encryption: none
# MANDATORY when using repokey: literal key passphrase or path to file
# containing the key passphrase. Ignored when using none encryption
encryption_passphrase: ~
# compression configuration, see borg manual
compression: auto,zstd,4
# define retention settings for borg independently from snapper
retention:
keep_last: 1
keep_hourly: 5
keep_daily: 7
keep_weekly: 0
keep_monthly: 0
keep_yearly: 0
# exclude patterns (see borg help patterns)
exclude_patterns: []
# MANDATORY: name of the snapper config
- name: home
# MANDATORY: borg repo target, e. g. backupuser@backuphost:reponame
repo: root@casaos:/media/casaos/12TB_HDD/Backups/oryp7/home
# if this is set to true, borg does not neccessarily fail when a backup fails
fault_tolerant_mode: true
# snapborg fails when the most recent snapshot transferred successfully is
# older than the time period given here. Set to '0d' to disable this behaviour
last_backup_max_age: 0d
# archive creation/storage options
storage:
# use either none or repokey encryption, defaults to none
encryption: none
# MANDATORY when using repokey: literal key passphrase or path to file
# containing the key passphrase. Ignored when using none encryption
encryption_passphrase: ~
# compression configuration, see borg manual
compression: auto,zstd,4
# define retention settings for borg independently from snapper
retention:
keep_last: 1
keep_hourly: 5
keep_daily: 7
keep_weekly: 0
keep_monthly: 0
keep_yearly: 0
# exclude patterns (see borg help patterns)
exclude_patterns: []
#+END_SRC #+END_SRC
*** Rofi Menu *** Rofi Menu
@ -7544,6 +7681,7 @@ help_menu() {
rofi_menu() { rofi_menu() {
declare -a options=( declare -a options=(
" - backup-to-hdd" " - backup-to-hdd"
" - backup-to-casaos"
" Back - back" " Back - back"
" Quit - quit" " Quit - quit"
) )
@ -7570,6 +7708,9 @@ main() {
--backup-to-hdd) --backup-to-hdd)
kitty --hold /home/sravan/.scripts/backup_to_hdd.sh kitty --hold /home/sravan/.scripts/backup_to_hdd.sh
;; ;;
--backup-to-casaos)
kitty --hold /home/sravan/.scripts/backup_to_casaos.sh
;;
--rofi) --rofi)
rofi_menu rofi_menu
;; ;;