Created
August 24, 2020 09:41
-
-
Save novoid/ee905b5fc6a1504ff8d3afd28d7b5453 to your computer and use it in GitHub Desktop.
vkbackup-system-config.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
VERSION="Time-stamp: <2019-10-10 17:18:58 vk>" | |
## This script backups several things to a given target directory | |
## Initial tings to backup are taken from: | |
## https://www.debian.org/releases/stretch/amd64/release-notes/ch-upgrading.en.html | |
## -> "4.1.1. Back up any data or configuration information" | |
## «The main things you'll want to back up are the contents of /etc, /var/lib/dpkg, /var/lib/apt/extended_states and | |
## the output of dpkg --get-selections "*" (the quotes are important).» | |
print_usage() | |
{ | |
########################################################################## | |
cat <<EOF | |
$0 | |
author: Karl Voit, tools@Karl-Voit.at | |
version: ${VERSION} | |
homepage: - | |
copyright: GPLv3 | |
usage: ${FILENAME} [<directory>] | |
example: ${FILENAME} /mnt/2TBbackup/vkbackup-system-config/ | |
... backups several system-specific settings to the target directory | |
Things that get backuped: | |
- directories: | |
- /etc | |
- /var/lib/dpkg | |
- /var/lib/apt/extended_states | |
- output of: | |
- dpkg --get-selections "*" | |
- crontab -u vk -l | |
- crontab -u root -l | |
EOF | |
########################################################################## | |
} | |
if [ $# -eq 0 ]; then | |
echo "\nERROR: no parameter found\n" | |
print_usage | |
exit 1 | |
elif [ -d "${1}" ]; then | |
DESTDIR="${1}" | |
rsync --archive --quiet --recursive --delete /etc ${DESTDIR}/ | |
rsync --archive --quiet --recursive --delete /var/lib/dpkg ${DESTDIR}/ | |
rsync --archive --quiet --recursive --delete /var/lib/apt/extended_states ${DESTDIR}/ | |
dpkg --get-selections "*" > ${DESTDIR}/dpkg_--get-selections.log | |
crontab -u vk -l > ${DESTDIR}/crontab_-u_vk_-l.log | |
crontab -u root -l > ${DESTDIR}/crontab_-u_root_-l.log | |
else | |
## parameter is no directory | |
echo "\nERROR: parameter is not a directory\n" | |
print_usage | |
exit 2 | |
fi | |
#end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment