Skip to content

Commit

Permalink
sysupgrade: Allow packages to specify their own ignore patterns
Browse files Browse the repository at this point in the history
The file /etc/sysignore.conf gives a global list of files patterns
to exclude from backup, but this list may become lengthy and
challenging to maintain in a single location.

As packages may specify their own files and directories to backup,
it makes sense that they can also manage their own rules of
exclusion from that list.

Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
  • Loading branch information
pprindeville committed Sep 17, 2023
1 parent d1351a5 commit 2d5d427
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Files that should never be backed up

core\.[1-9]
core\.[1-9][0-9]
core\.[1-9][0-9][0-9]
core\.[1-9][0-9][0-9][0-9]
core\.[1-9][0-9][0-9][0-9][0-9]
8 changes: 6 additions & 2 deletions package/base-files/files/sbin/sysupgrade
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ while [ -n "$1" ]; do
done

export CONFFILES=/tmp/sysupgrade.conffiles
export IGNOREFILES=/tmp/sysupgrade.ignore
export CONF_TAR=/tmp/sysupgrade.tgz
export ETCBACKUP_DIR=/etc/backup
export INSTALLED_PACKAGES=${ETCBACKUP_DIR}/installed_packages.txt
Expand Down Expand Up @@ -255,9 +256,12 @@ do_save_conffiles() {
\) | sed -e 's,.*/,,;s/\.control /\t/' > ${INSTALLED_PACKAGES}
fi

sed -ne '/^[[:space:]]*$/d; /^#/d; p' \
/etc/sysignore.conf /lib/upgrade/ignore.d/* > "$IGNOREFILES"

v "Saving config files..."
[ "$VERBOSE" -gt 1 ] && TAR_V="v" || TAR_V=""
tar c${TAR_V}zf "$conf_tar" -T "$CONFFILES" -X /etc/sysignore.conf 2>/dev/null
tar c${TAR_V}zf "$conf_tar" -T "$CONFFILES" -X "$IGNOREFILES" 2>/dev/null
if [ "$?" -ne 0 ]; then
echo "Failed to create the configuration backup."
rm -f "$conf_tar"
Expand All @@ -268,7 +272,7 @@ do_save_conffiles() {
umount "$ETCBACKUP_DIR"
rm -rf "$RAMFS"
}
rm -f "$CONFFILES"
rm -f "$CONFFILES" "$IGNOREFILES"
}

if [ $CONF_BACKUP_LIST -eq 1 ]; then
Expand Down

0 comments on commit 2d5d427

Please sign in to comment.