User Tools

Site Tools


backup_with_rsync

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
backup_with_rsync [2026/02/04 21:55] – created stevebackup_with_rsync [2026/02/06 16:06] (current) – Just adding more notes. steve
Line 1: Line 1:
 ==== Backup with rsync ==== ==== Backup with rsync ====
 +So, this is what I've been doing to make backups of machines for years, it stores permissions, and you can export the /Backup folder via NFS, then remap it to another folder as read-only so users can do their own restores if you want (not going into that here).  The reason that the *.conf files start with 00 and 01 is just to set the order that things are backed up, the ''**for Script in *.conf**'' part below goes in lexical order.\\
 +\\
 +This is what I see in my /Backup folder with;\\
 +''**ls -Al /Backup**''.
 <code bash> <code bash>
-## Type ↓ ↓ ↓, User stejon0jadmin in ~ on usmiftnilnx001 ## 
-ls -Al /Backup 
 total 64 total 64
 drwxr-xr-x 12 root root  4096 2026-02-04+15:20:02 00-EFI drwxr-xr-x 12 root root  4096 2026-02-04+15:20:02 00-EFI
Line 12: Line 14:
 -rwx------  1 root root   333 2024-06-27+13:17:20 SystemBackup -rwx------  1 root root   333 2024-06-27+13:17:20 SystemBackup
 </code> </code>
 +\\ 
 +Below is a short script that just runs the actual backup script with different sets of options for what goes where;\\ 
 +''**sudo cat /Backup/SystemBackup**''
 <code bash /Backup/SystemBackup> <code bash /Backup/SystemBackup>
-## Type ↓ ↓ ↓, User stejon0jadmin in ~ on usmiftnilnx001 ## 
-sudo cat /Backup/SystemBackup 
 #!/bin/bash #!/bin/bash
 # make sure we're running as root # make sure we're running as root
Line 30: Line 32:
 cat /Backup/*/Summary cat /Backup/*/Summary
 </code> </code>
 +\\ 
 +The .conf script below that gets sourced by the backup script below that;\\ 
 +''**sudo cat /Backup/01-Root.conf**'' 
 +<code bash /Backup/01-Root.conf> 
 +# =-=-=-=-=-=- File locations and variables.  -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= 
 +# Where to write the backups, begins with / only. 
 +        SNAPSHOT_RW=/Backup/01-Root; 
 +# What directory to back up, begins and ends in /. 
 +        SNAP_DIR="/"; 
 +# Where to store the list of files and directories that we backed up. 
 +        FILELIST=$SNAPSHOT_RW/Filelist 
 +# Summary file, a short list of actions taken by rsync to complete the backup. 
 +        SUMMARY=$SNAPSHOT_RW/Summary 
 +# Stuff not to back up, there is always stuff to not back up! 
 +        EXCLUDES=$SNAPSHOT_RW/Excludes; 
 +# How many snapshot backups do we want to keep? Must be at least 2! 
 +        NUM_SNAP=10;  
 +</code> 
 +\\ 
 +Below is the actual script that calls rsync to do the backup, into a unique folder-by-date.\\ 
 +''**sudo cat /Backup/Snapshot**''
 <code bash /Backup/Snapshot> <code bash /Backup/Snapshot>
-## Type ↓ ↓ ↓, User stejon0jadmin in ~ on usmiftnilnx001 ## 
-sudo cat /Backup/Snapshot 
 #!/bin/bash #!/bin/bash
 # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Line 142: Line 162:
 #  } fi; #  } fi;
 </code> </code>
 +\\ 
 +The /Backup/01-Root/Excludes file is important, there's always stuff you don't want backed up (some things can't be as they recursively call themselves) and this is a list that has been created over years of 'what the heck happened' moments;\\ 
 +''**sudo cat /Backup/01-Root/Excludes**''
 <code text /Backup/01-Root/Excludes> <code text /Backup/01-Root/Excludes>
-## Type ↓ ↓ ↓, User stejon0jadmin in ~ on usmiftnilnx001 ## 
-sudo cat /Backup/01-Root/Excludes 
 /Backup/* /Backup/*
 /home/Shared/Backup /home/Shared/Backup
Line 164: Line 184:
 /var/lib/docker/* /var/lib/docker/*
 </code> </code>
 +\\ 
 +And, what's in the partition backup folder;\\ 
 +''**ls -Al /Backup/01-Root/**''
 <code bash> <code bash>
-## Type ↓ ↓ ↓, User stejon0jadmin in ~ on usmiftnilnx001 ## 
-ls -Al /Backup/01-Root/ 
 total 52 total 52
 drwxr-xr-x 44 root root 4096 2026-01-26+15:21:57 2026-01-26-20-20 drwxr-xr-x 44 root root 4096 2026-01-26+15:21:57 2026-01-26-20-20
Line 183: Line 203:
 -rw-r--r--  1 root root  349 2026-02-04+15:23:10 Summary -rw-r--r--  1 root root  349 2026-02-04+15:23:10 Summary
 </code> </code>
 +\\ 
 +The Summary file is a quick recap of what happened during the last backup;\\ 
 +''**sudo cat /Backup/01-Root/Summary**''
 <code bash> <code bash>
-## Type ↓ ↓ ↓, User stejon0jadmin in ~ on usmiftnilnx001 ## 
-sudo cat /Backup/01-Root/Summary 
 sending incremental file list sending incremental file list
 created directory /Backup/01-Root/2026-02-04-20-20 created directory /Backup/01-Root/2026-02-04-20-20
Line 196: Line 216:
 total size is 264,243,317,875  speedup is 114.13 total size is 264,243,317,875  speedup is 114.13
 </code> </code>
 +\\ 
 +Backing up another partition requires only to create another .conf file, creating the folder to drop the backups into, and copying the 'Excludes' file there.\\ 
 +Below is the .conf for the EFI partition;\\ 
 +''**sudo cat /Backup/00-EFI.conf**'' 
 +<code bash /Backup/00-EFI.conf> 
 +# =-=-=-=-=-=- File locations and variables.  -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= 
 +# Where to write the backups, begins with / only. 
 +        SNAPSHOT_RW=/Backup/00-EFI; 
 +# What directory to back up, begins and ends in / 
 +        SNAP_DIR="/boot/efi/"; 
 +# Where to store the list of files and directories that we backed up. 
 +        FILELIST=$SNAPSHOT_RW/Filelist 
 +# Summary file, a short list of actions taken by rsync to complete the backup. 
 +        SUMMARY=$SNAPSHOT_RW/Summary 
 +# Stuff not to back up, there is always stuff to not back up! 
 +        EXCLUDES=$SNAPSHOT_RW/Excludes; 
 +# How many snapshot backups do we want to keep? Must be at least 2! 
 +        NUM_SNAP=10; 
 +</code> 
 +\\ 
 +Other stuff;\\ 
 +In one of the date points in the backup folder, there are a few added files, ''**/Backup/01-Root/2026-02-04-20-20/Filelist**'' and a copy of the Summary file; 
 +''**sudo ls -Al /Backup/01-Root/2026-02-04-20-20/**'' 
 +<code bash> 
 +total 8389772 
 +drwxr-xr-x   2 root root       4096 Nov 26  2024 Backup 
 +lrwxrwxrwx  10 root root          7 Apr 22  2024 bin -> usr/bin 
 +drwxr-xr-x   2 root root       4096 Feb 26  2024 bin.usr-is-merged 
 +drwxr-xr-x   4 root root       4096 Feb  3 11:10 boot 
 +drwxr-xr-x   2 root root       4096 Feb  4 14:46 dev 
 +drwxr-xr-x 149 root root      12288 Feb  4 14:30 etc 
 +-rw-------   1 root root    1000059 Feb  4 15:23 Filelist 
 +drwxr-xr-x   6 root root       4096 Jan 15  2025 home 
 +drwxr-xr-x   2 root root       4096 Feb  3 11:07 i18n 
 +lrwxrwxrwx  10 root root          7 Apr 22  2024 lib -> usr/lib 
 +lrwxrwxrwx  10 root root          9 Apr 22  2024 lib64 -> usr/lib64 
 +drwxr-xr-x   2 root root       4096 Feb 26  2024 lib.usr-is-merged 
 +drwx------   2 root root       4096 Jun 27  2024 lost+found 
 +drwxr-xr-x   2 root root       4096 Jun 27  2024 media 
 +drwxr-xr-x   2 root root       4096 Apr 23  2024 mnt 
 +drwxr-xr-x  12 root root       4096 Aug 27 00:14 opt 
 +dr-xr-xr-x   2 root root       4096 Feb  3 11:06 proc 
 +drwx------  12 root root       4096 Feb  3 10:54 root 
 +drwxr-xr-x   2 root root       4096 Feb  4 14:46 run 
 +lrwxrwxrwx  10 root root          8 Apr 22  2024 sbin -> usr/sbin 
 +drwxr-xr-x   2 root root       4096 Apr  3  2024 sbin.usr-is-merged 
 +drwxr-xr-x   2 root root       4096 Apr 23  2024 srv 
 +-rw-r--r--  10 root root        116 Jun 27  2024 Summary 
 +dr-xr-xr-x   2 root root       4096 Feb  3 15:22 sys 
 +drwxrwxrwt   2 root root       4096 Feb  4 14:46 tmp 
 +drwxr-xr-x  12 root root       4096 Apr 23  2024 usr 
 +drwxr-xr-x  14 root root       4096 Jun 27  2024 var 
 +</code> 
 +Notice above that the actual files (the soft links) in this folder have inode counts of 10. That means that they haven't changed in all of the backups, it's only a single file in the /Backup sub-folder, with hard links in pointing at the original file.\\ 
 +\\ 
 +Below, you can see that files that change every day change their link count;\\ 
 +''**sudo ls -l /Backup/01-Root/*/var/log/unattended-upgrades/unattended-upgrades.log**'' 
 +<code bash> 
 +-rw-r--r-- 1 root root 22146 Jan 26 06:47 /Backup/01-Root/2026-01-26-20-20/var/log/unattended-upgrades/unattended-upgrades.log 
 +-rw-r--r-- 1 root root 23063 Jan 27 12:44 /Backup/01-Root/2026-01-27-20-20/var/log/unattended-upgrades/unattended-upgrades.log 
 +-rw-r--r-- 1 root root 23992 Jan 28 06:45 /Backup/01-Root/2026-01-28-20-20/var/log/unattended-upgrades/unattended-upgrades.log 
 +-rw-r--r-- 1 root root 24790 Jan 29 06:35 /Backup/01-Root/2026-01-29-20-20/var/log/unattended-upgrades/unattended-upgrades.log 
 +-rw-r--r-- 1 root root 28212 Jan 30 09:05 /Backup/01-Root/2026-01-30-20-20/var/log/unattended-upgrades/unattended-upgrades.log 
 +-rw-r--r-- 1 root root 31634 Jan 31 12:40 /Backup/01-Root/2026-01-31-20-20/var/log/unattended-upgrades/unattended-upgrades.log 
 +-rw-r--r-- 1 root root  3422 Feb  1 14:22 /Backup/01-Root/2026-02-01-20-20/var/log/unattended-upgrades/unattended-upgrades.log 
 +-rw-r--r-- 1 root root  6844 Feb  2 06:21 /Backup/01-Root/2026-02-02-20-20/var/log/unattended-upgrades/unattended-upgrades.log 
 +-rw-r--r-- 1 root root 10096 Feb  3 06:09 /Backup/01-Root/2026-02-03-20-20/var/log/unattended-upgrades/unattended-upgrades.log 
 +-rw-r--r-- 1 root root 11239 Feb  4 08:39 /Backup/01-Root/2026-02-04-20-20/var/log/unattended-upgrades/unattended-upgrades.log 
 +</code>
backup_with_rsync.1770242147.txt.gz · Last modified: by steve