pkg prime-list
would give you that. As for the OS or configuration, you want to backup /boot/loader.conf, /etc/rc.conf, /etc/sysctl.conf and relevant configuration files in /usr/local/etc/. Then you also want to include your /usr/home home directories. zfs-send(8) creates a filestream of the dataset. You can redirect this to a file, backup that file on some other media. It can be restored using zfs-receive(8).How would such a backup happen if it's a zfs system?
But will this method back-up the state of the applications? eg would a Chromium instance on original setup with all it's tabs/logins open be backed up to work the same way on the backupDon't backup the OS or your packages. It's usually quicker to reinstall than restoring from backup. You do want to make a list of relevant packages that are installed;pkg prime-list
would give you that.
Does this back-up everything at once or is this some kind of incremental backup ?zfs-send(8) creates a filestream of the dataset. You can redirect this to a file, backup that file on some other media. It can be restored using zfs-receive(8).
What options are usually the best?rsync with all its filtering options is the king of selective backup.
How does one check which files are relevant? given a system that's been running for a couple of years.and relevant configuration files in /usr/local/etc/
You're backing up files, not the state of the memory. Configuration of chromium is stored in your home directory. Which is something you definitely want to backup.But will this method back-up the state of the applications? eg would a Chromium instance on original setup with all it's tabs/logins open be backed up to work the same way on the backup
That's up to you. Both are possible.Does this back-up everything at once or is this some kind of incremental backup ?
You configured it, so I would hope you also recorded somewhere what and how you configured it. I can't tell you what you did, so can't tell you exactly which files. But you could just backup the entire /usr/local/etc/ directory for good measure.How does one check which files are relevant? given a system that's been running for a couple of years.
What is the difference betweenYou do want to make a list of relevant packages that are installed;pkg prime-list
would give you that.
pkg prime
and pkg query -e '%a = 0' %o | awk -F '/' '{print $2}' | sort
?Definitely recommend putting /usr/home (or /home) on a separate dataset (or a separate partition if you use UFS). On some systems I even create a separate home directory dataset for each user account. Makes it a lot easier to backup the home directories.I've preferred to keep my user data (home directory and shared space) on different devices from the OS, makes it easy to mirror user data or to upgrade OS by installing a new device and fresh install to it.
I take note of pkg prime-list that I didn't know , thank you.You do want to make a list of relevant packages that are installed;pkg prime-list
would give you that
#!/usr/bin/env sh
_bkp_loc="$HOME/bkp"
_sys_conf_loc1="/etc"
_sys_conf_loc2="/usr/local/etc"
_sys_bkp_conf_loc="$_bkp_loc$_sys_conf_loc1"
_sys_bkp_conf_loc2="$_bkp_loc$_sys_conf_loc2"
_home_conf="${HOME}/.config"
_home_local="${HOME}/.local"
_home_bkp="${_bkp_loc}/home/beastie"
bkp_sys(){
pkg prime-list > "${_bkp_loc}"/pkg_list.txt
cp -a -f -v /boot/loader.conf "${_bkp_loc}"/boot/.
cp -a -f -v "${_sys_conf_loc1}"/profile "${_sys_bkp_conf_loc}"/.
cp -a -f -v "${_sys_conf_loc1}"/devfs.conf "${_sys_bkp_conf_loc}"/.
cp -a -f -v "${_sys_conf_loc1}"/devfs.rules "${_sys_bkp_conf_loc}"/.
cp -a -f -v "${_sys_conf_loc1}"/rc.conf "${_sys_bkp_conf_loc}"/.
cp -a -f -v "${_sys_conf_loc1}"/sysctl.conf "${_sys_bkp_conf_loc}"/.
cp -a -f -v "${_sys_conf_loc1}"/fstab "${_sys_bkp_conf_loc}"/.
cp -a -f -v "${_sys_conf_loc1}"/motd.template "${_sys_bkp_conf_loc}"/.
cp -a -f -v "${_sys_conf_loc2}"/doas.conf "${_sys_bkp_conf_loc2}"/.
cp -a -f -v "${_sys_conf_loc2}"/openvpn "${_sys_bkp_conf_loc2}"/.
cp -a -f -v "${_sys_conf_loc2}"/X11 "${_sys_bkp_conf_loc2}"/.
cp -a -f -v "${_sys_conf_loc2}"/smartd.conf "${_sys_bkp_conf_loc2}"/.
doas cp -a -f -v "${_sys_conf_loc2}"/polkit-1/rules.d/xfce.rules "${_sys_bkp_conf_loc2}"/polkit-1/rules.d/.
}
bkp_home(){
cp -a -f -v "${HOME}"/.beastie "${_home_bkp}"/.
cp -a -f -v "${HOME}"/.cshrc "${_home_bkp}"/.
cp -a -f -v "${HOME}"/.cwmrc "${_home_bkp}"/.
cp -a -f -v "${HOME}"/.fehbg "${_home_bkp}"/.
cp -a -f -v "${HOME}"/.login_conf "${_home_bkp}"/.
cp -a -f -v "${HOME}"/.tcshrc "${_home_bkp}"/.
cp -a -f -v "${HOME}"/.zshrc "${_home_bkp}"/.
cp -a -f -v "${HOME}"/.welcome "${_home_bkp}"/.
cp -a -f -v "${HOME}"/.Xdefaults "${_home_bkp}"/.
cp -a -f -v "${HOME}"/.xinitrc "${_home_bkp}"/.
cp -a -f -v "${HOME}"/xinitrc-xfce "${_home_bkp}"/.
cp -a -f -v "${HOME}"/xinitrcwm "${_home_bkp}"/.
cp -a -f -v "${HOME}"/.moc "${_home_bkp}"/.
cp -a -f -v "${_home_conf}"/dunst "${_home_bkp}"/config/.
cp -a -f -v "${_home_conf}"/fish "${_home_bkp}"/config/.
cp -a -f -v "${_home_conf}"/nano "${_home_bkp}"/config/.
cp -a -f -v "${_home_conf}"/pcmanfm "${_home_bkp}"/config/.
cp -a -f -v "${_home_conf}"/qt5ct "${_home_bkp}"/config/.
cp -a -f -v "${_home_conf}"/xfe "${_home_bkp}"/config/.
cp -a -f -v "${_home_local}"/bin "${_home_bkp}"/dot-local/.
}
bkp_sys && bkp_home && echo "Done!" && exit 0
#!/usr/bin/env sh
cd ~/bkp
git add *
printf '%s\n' 'Commit message?'
read _m
git commit -m "${_m}"
git push origin main
exit 0
#!/usr/bin/env bash
_date=`date "+%Y-%m-%d"`
_disk_dest="/zmedia/zbkp/zhome"
_bkp_dest="$_disk_dest/$_date"
mkdir "${_bkp_dest}"
bkp_files(){
_dirs=("bkp" "Desktop" "Documents" "Downloads" "Monero" "Music" "Pictures" "Public" "Templates" "tmp" "Videos")
cd "$_bkp_dest"
for d in "${_dirs[@]}"; do
echo "Copying $HOME/$d to $_bkp_dest/$d.tar.lz4"
tar --use-compress-program=lz4 -cf "$d".tar.lz4 "$HOME"/"$d"
done
cd
}
bkp_files && echo "Done!" && exit 0
But will this method back-up the state of the applications? eg would a Chromium instance on original setup with all it's tabs/logins open be backed up to work the same way on the backup
Does this back-up everything at once or is this some kind of incremental backup ?
What options are usually the best?
How does one check which files are relevant? given a system that's been running for a couple of years.
rsnapshot
).You configured it, so I would hope you also recorded somewhere what and how you configured it.
However, my view is that disk capacity is cheap these days. A typical FreeBSD root (without user data) would generally not need to exceed 25GB. You can get high capacity external USB3 disks for US$20/TB. That's peanuts.
Recently I had an unexpected power failure happened with some physical server.Don't backup the OS or your packages
rsync -c -n / rsync://remotebackup/
Just to rsync all files to another HDD or remote storage (excluding apparently temporary and extralarge like snapshots).How should a backup of the system be done? (along with applications/data/permissions preserved)
#Copy directory hierarchy / to /mnt/root
cd / ; pax -p eme -X -rw . /mnt/root
#Copy from local to remote
cd /; pax -w -X . | ssh root@hostname "cd /mnt/root && pax -r -v -p eme"
#Copy from remote to current local directory
ssh root@hostname "cd /mnt/a && pax -w -X . " | pax -r -v -p eme
What options are usually the best?
#!/bin/sh
date_now=`date "+%Y%m%d-%H%M"`
rsync -Hav --exclude-from=/root/bin/backup.exclude --numeric-ids --bwlimit=400 --log-file=/var/log/backup-${date_now} --password-file=/root/bin/backup.rsyncpwd / backup@127.0.0.1::backup/
#--delete is required for mirroring hierarchy but doublecheck a name and content of the target directory
Beside the already named: If you use f.e. something like rsync for your backup (as I do among other tools) take care of the file system of your backup drive; The often used combination "NAS & Samba" won't take care of your file permissions (a NAS for unix backups should IMO at least offer the ext* file system and SSH as well as NFS); Instead by using something like "tar" will preserve file permissions even on a FAT file system, but won't be as comfortable when it comes to restore your data.How should a backup of the system be done? (along with applications/data/permissions preserved)
For me there's nothing related to the source filesystem.How would such a backup happen if it's a zfs system?
Just for the sake of correctness, dump(8) actually supports nodump flag, see -h option and chflags(1).The most complete way to do it for UFS is dump(8). But like zfs-send it doesn't allow you to pick or exclude files.
I need that for files/directories I write. For keeping remote copies ofI always been searching for a "time-machine" substitute, especially the aspect of selectively retrieving past versions of a certain file/directory.
You can just export entire ZFS Boot Environment to a file and you have entire system secured.How should a backup of the system be done? (along with applications/data/permissions preserved)
What are the folders/files that are most essential ?
How would such a backup happen if it's a zfs system?
# beadm list
BE Active Mountpoint Space Created
13.1 NR / 33.4G 2023-01-10 16:55
13.1.safe - - 2.1G 2023-01-20 17:09
# beadm export 13.1 | xz -9 > 13.1.BE.xz
# xz -c -d 13.1.BE.xz | beadm import 13.1.RESTORE
# beadm list
BE Active Mountpoint Space Created
13.1 NR / 33.4G 2023-01-10 16:55
13.1.safe - - 2.1G 2023-01-20 17:09
13.1.RESTORE - - 31.2G 2023-02-06 18:15
# beadm activate 13.1.RESTORE
# xz -c -d 13.1.BE.xz | beadm import 13.1.RESTORE
# beadm activate 13.1.RESTORE
# reboot
You can also use the same method to 'move' your system to other/new hardware or between VM and a real hardware. Hope that helps.