Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen angezeigt.

Link zu dieser Vergleichsansicht

Beide Seiten der vorigen Revision Vorhergehende Überarbeitung
content:serverbasics:server-backup [2025/03/28 19:55] Danielcontent:serverbasics:server-backup [2025/03/29 12:22] (aktuell) – [Cron- Job] Daniel
Zeile 1: Zeile 1:
 ====== Server: Backup ====== ====== Server: Backup ======
  
-There are many ways to backup your server. As NC-AIO already has Borg, you may use Borg for a complete Backup of your system. The docs can be found here: https://borgbackup.readthedocs.io/en/stable/+There are many ways to backup your server. As NC-AIO already has Borg, you may use Borg for a complete Backup of your system. The docs can be found here: [[https://borgbackup.readthedocs.io/en/stable/|https://borgbackup.readthedocs.io/en/stable/]]
  
 You need to perform everything as root. So login as root somehow (maybe use ''sudo -i'') You need to perform everything as root. So login as root somehow (maybe use ''sudo -i'')
Zeile 9: Zeile 9:
  
   * /backup (should already be there by NC-AIO)   * /backup (should already be there by NC-AIO)
-  * /backup/mnt 
   * /backup/borg/root   * /backup/borg/root
  
-Please refer to the Documentations of Borg found at https://borgbackup.readthedocs.io/en/stable/usage/init.html to create a Repository. You can also use some graphical tool like vorta for this - i did, while it will help to setup borg.+Please refer to the Documentations of Borg found at [[https://borgbackup.readthedocs.io/en/stable/usage/init.html|https://borgbackup.readthedocs.io/en/stable/usage/init.html]] to create a Repository. You can also use some graphical tool like vorta for this - i did, while it will help to setup borg.
  
 For me, i chose the location ''/backup/borg/root''  as repository. I included the key, so that i only needed a new passphrase to access the repository: For me, i chose the location ''/backup/borg/root''  as repository. I included the key, so that i only needed a new passphrase to access the repository:
- 
 <code> <code>
 +
 borg init --encryption repokey-blake2 /backup/borg/root borg init --encryption repokey-blake2 /backup/borg/root
  
 </code> </code>
 +
 ===== Setup a Script ===== ===== Setup a Script =====
  
Zeile 35: Zeile 35:
  
 echo "Starting Backup of Root with Borg" echo "Starting Backup of Root with Borg"
-#This will create a btrfs readonly snapshot of root in the directory /backup/mnt/root_snapshot +#This will create a btrfs readonly snapshot of root in the directory /root_snapshot 
-mkdir -p /backup/mnt/root_snapshot +/sbin/btrfs subvolume snapshot -r / /root_snapshot
-btrfs subvolume snapshot -r / /backup/mnt/root_snapshot+
 echo "Creating Archive ${ARCHIVNAME} in ${REPONAME}..." echo "Creating Archive ${ARCHIVNAME} in ${REPONAME}..."
-/usr/bin/borg create --warning --show-version --list --filter=AM --show-rc -s -C lz4 --exclude-from /root/backup/excludelist ${REPONAME}::${ARCHIVNAME} /backup/mnt/root_snapshot /boot/grub2/i386-pc /boot/grub2/x86_64-efi /opt /root /srv /tmp /usr/local /var /boot/efi /home+/usr/bin/borg create --warning --show-version --list --filter=AM --show-rc -s -C lz4 --exclude-from /root/backup/excludelist ${REPONAME}::${ARCHIVNAME} /root_snapshot /boot/grub2 /i386-pc /boot/grub2/x86_64-efi /opt /root /srv /tmp /usr/local /var /boot/efi /home
 RETURNCODE=$? RETURNCODE=$?
-btrfs subvolume delete /backup/mnt/root_snapshot+/sbin/btrfs subvolume delete /root_snapshot
 if [ ${RETURNCODE} -ne 0 ]; then if [ ${RETURNCODE} -ne 0 ]; then
-  echo "Some ERROR with Borg. Stopping execution." + echo "Some ERROR with Borg. Stopping execution." 
-  exit ${RETURNCODE}+ exit ${RETURNCODE}
 fi fi
  
Zeile 183: Zeile 182:
  
 </file> </file>
 +
 ===== Cron- Job ===== ===== Cron- Job =====
  
Zeile 192: Zeile 192:
 cd /root/backup cd /root/backup
 ./borg_backup_root.sh> $0.log 2>&1 ./borg_backup_root.sh> $0.log 2>&1
 +cat $0.log
  
 </file> </file>
  • content/serverbasics/server-backup.txt
  • Zuletzt geändert: 2025/03/29 12:22
  • von Daniel