diff --git a/.gitignore b/.gitignore index 105e95d..de19d2f 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,6 @@ !backup.timer !exclude-list-S551LN.txt !README.md +!Makefile +!.gitignore +* diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..e7a9a6d --- /dev/null +++ b/Makefile @@ -0,0 +1,13 @@ +systemd_path := /etc/systemd/system +install: + cp borgbackup.* $(systemd_path)/ + chmod a+x $(systemd_path)/borgbackup.* + systemctl edit borgbackup.service + systemctl enable borgbackup.timer + systemctl start borgbackup.timer + +uninstall: + systemctl disable borgbackup.timer + rm -rvf $(systemd_path)/borgbackup.service + rm -rvf $(systemd_path)/borgbackup.timer + rm -rvf /etc/systemd/system/borgbackup.service.d diff --git a/README.md b/README.md index 542be43..915f0e2 100644 --- a/README.md +++ b/README.md @@ -1 +1,22 @@ # Backup configuration for S551LN laptop + +## Install + +- run the command `make install` as admin +- in the editor that opens, write the following configuration: + ``` + [Service] + Environment=BORG_REPO=/path/to/borg/repo + Environment=BORG_PASSPHRASE=somEp4$sphrase + Environment=EXCLUDE_LIST=/path/to/exclude/list + ``` + +## Uninstall + +`make uninstall` + +## Run manual backup + +- use `systemctl start borgbackup.service` to run a backup manually +- use `journalctl -u borgbackup.service` to view the logs + diff --git a/borgbackup.service b/borgbackup.service new file mode 100644 index 0000000..c2505a0 --- /dev/null +++ b/borgbackup.service @@ -0,0 +1,12 @@ +[Unit] +Description=Borg backup + +[Service] +Type=oneshot +Environment=BORG_HOSTNAME_IS_UNIQUE=yes +Nice=19 +ExecStart=/usr/bin/borg create --list --stats --filter AME --exclude-from=${EXCLUDE_LIST} ::{now} / +ExecStartPost=/usr/bin/borg prune -v --list --keep-daily=7 --keep-weekly=4 --keep-monthly=10 --keep-within 2d --stats :: + +[Install] +WantedBy=multi-user.target diff --git a/borgbackup.timer b/borgbackup.timer new file mode 100644 index 0000000..f8e9e25 --- /dev/null +++ b/borgbackup.timer @@ -0,0 +1,9 @@ +[Unit] +Description=Borgbackup + +[Timer] +OnBootSec=30min +OnCalendar=0/4:00:00 + +[Install] +WantedBy=timers.target diff --git a/exclude-list-S551LN.txt b/exclude-list-S551LN.txt new file mode 100644 index 0000000..728f309 --- /dev/null +++ b/exclude-list-S551LN.txt @@ -0,0 +1,49 @@ +/proc +/sys +/dev +/media +/cdrom +/tmp +/run +/var/cache +/var/tmp +/var/run +/home/*/.thumbnails +/home/*/.cache/chromium +/home/*/.cache/mozilla +/home/*/.cache/wine +/home/*/.steam/steam/steamapps +/home/*/.steam/steam/config/htmlcache +/home/*/.local/share/Trash +/home/*/.mozilla/firefox/*.default/Cache +/home/*/.gvfs +/swapfile + +/var/lib/flatpak/appstream/ +/var/lib/flatpak/repo/ + +/root/.cache + +/home/*/.android +/home/*/.cache +/home/*/.m2 +/home/*/.gradle +/home/*/Vidéos +/home/*/Musique +/home/*/Téléchargements +/home/*/Virtualbox_VMS +/home/*/ISO +/home/*/Android + +/mnt/!data +/mnt/data/thibaud/.m2 +/mnt/data/thibaud/.gradle +/mnt/data/thibaud/backups +/mnt/data/thibaud/Vidéos +/mnt/data/thibaud/Musique +/mnt/data/thibaud/Téléchargements +/mnt/data/thibaud/Virtualbox_VMS +/mnt/data/thibaud/tmp +/mnt/data/thibaud/ISO +/mnt/data/thibaud/Android +*.!qB