Skip to content

Instantly share code, notes, and snippets.

@likuku
Last active October 12, 2022 08:58
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save likuku/5589316 to your computer and use it in GitHub Desktop.
Save likuku/5589316 to your computer and use it in GitHub Desktop.
Build a package for your linux (building package on OS running),you can use it for backup or quick install. It was on debian and ubuntu work well. I haven't tested in other distribution.
#!/usr/bin/env bash
# Warning!
# if you DIY a stage package like this,
# you must use the Stage3`s /etc/udev/*
# or rm /etc/udev/rules.d/70*
# Warning!
# Update by likuku on Nov29,2016
readonly DATE=$(date +%Y_%m_%d_%H_%M_%S)
readonly ARCH=$(uname -m)
readonly HOSTNAME=$(uname -n)
readonly ROOTFS_TYPE=$(mount | grep -i "on / type" | grep -vi "rootfs" | awk '{print $5}')
readonly BACKUP_PATH=$(pwd)
readonly STAGE5NAME="stage5_${ARCH}_${ROOTFS_TYPE}_${HOSTNAME}.${DATE}.tgz"
cd /;
tar czpvf ${BACKUP_PATH}/${STAGE5NAME} \
--exclude=.${BACKUP_PATH}/*.tgz \
--exclude=.${BACKUP_PATH}/*.sha256sum \
--exclude=./etc/udev/rules.d/30* \
--exclude=./etc/udev/rules.d/61* \
--exclude=./etc/udev/rules.d/70* \
--exclude=./etc/udev/rules.d/80* \
--exclude=./etc/udev/rules.d/90* \
--exclude=./proc/* \
--exclude=./sys/* \
--exclude=./var/log/dmesg \
--exclude=./var/log/*log \
--exclude=./var/log/messages* \
--exclude=./var/log/wtmp* \
--exclude=./var/log/portage/elog/* \
--exclude=./var/tmp/* \
--exclude=./usr/portage/distfiles/* \
--exclude=./o/* \
--exclude=./export/* \
--exclude=./tmp/* \
.
#--exclude=./etc/ssh/ssh_host* \
#--exclude=./home/* \
#--exclude=./usr/portage/* \
wait;
cd ${BACKUP_PATH};
sha256sum ${STAGE5NAME} >${STAGE5NAME}.sha256sum
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment