-
-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enable build-in/internal CBSD backup DB script
Make a backup (+rotation) of the environment SQLite3 databases and the main index CBSD database before applying migrations. User can regulate behavior via ~cbsd/etc/initenv.conf config files, e.g.: initenv_backup_bases=0 to disable backup function; initenv_backup_bases=X where X - any positive number: store the X number of copies. Also, the user can write any of his own scripts at this stage via ~cbsd/upgrade/ directory: .. /usr/bin/find ${workdir}/upgrade/ -mindepth 1 -maxdepth 1 -type f -name pre-initenv-\* -exec {} \; .. /usr/bin/find ${distdir}/upgrade/ -mindepth 1 -maxdepth 1 -type f -name pre-patch-\* -exec {} \; + post-hook: .. /usr/bin/find ${distdir}/upgrade/ -mindepth 1 -maxdepth 1 -type f -name post-patch-\* -exec {} \; .. /usr/bin/find ${workdir}/upgrade/ -mindepth 1 -maxdepth 1 -type f -name post-initenv-\* -exec {} \; Suggested and Thanks to: @kraileth
- Loading branch information
Showing
4 changed files
with
144 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# pre-initenv auto DB backups | ||
# How many SQLite3 DB backups to keep, '0' - turn off. | ||
initenv_backup_bases=3 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# don't remove this line: | ||
vm_profile="Manjaro-x86-2023" | ||
vm_os_type="linux" | ||
# this is one-string additional info strings in dialogue menu | ||
long_description="Manjaro Linux: 23.1.4" | ||
|
||
# custom settings: | ||
fetch=1 | ||
|
||
# Official resources to fetch ISO's | ||
iso_site="\ | ||
https://download.manjaro.org/kde/23.1.4/ \ | ||
" | ||
|
||
# Official CBSD project mirrors | ||
# mirrors maintainer: | ||
# mirror2.bsdstore.ru: olevole at olevole dot ru | ||
# electro.bsdstore.ru: olevole at olevole dot ru | ||
# mirror.bsdstore.ru: olevole at olevole dot ru | ||
# clonos.ca.ircdriven.net clonos.us.ircdriven.net: onecoldworld at gmail dot com | ||
# plug-mirror.rcac.purdue.edu: plug-mirror at lists dot purdue dot edu | ||
cbsd_iso_mirrors="https://mirror2.bsdstore.ru/iso/ http://electro.bsdstore.ru/iso/ https://mirror.bsdstore.ru/iso/ https://clonos.ca.ircdriven.net/iso/ https://clonos.us.ircdriven.net/iso/ https://electrode.bsdstore.ru/iso/ https://plug-mirror.rcac.purdue.edu/cbsd-iso/" | ||
|
||
iso_img="manjaro-kde-23.1.4-240406-linux66.iso" | ||
|
||
# register_iso as: | ||
register_iso_name="cbsd-iso-${iso_img}" | ||
register_iso_as="iso-${iso_img}" | ||
|
||
default_jailname="manj" | ||
# At least 8 GiB is required | ||
imgsize="9g" | ||
|
||
#virtio_type="ahci-hd" | ||
virtio_type="virtio-blk" | ||
|
||
# mouse not work with tablet=1 | ||
tablet=0 | ||
|
||
# VNC | ||
vm_vnc_port="0" | ||
vm_efi="uefi" | ||
|
||
# disable profile? | ||
xen_active=1 | ||
bhyve_active=1 | ||
qemu_active=1 | ||
|
||
# Available in ClonOS? | ||
clonos_active=1 | ||
sha256sum="31872ded447254e4531b6877f8894300b7a96e5d39a9e7b806498db033ec9bca" | ||
iso_img_dist_size="3839172608" | ||
|
||
# enable birtio RNG interface? | ||
virtio_rnd="1" | ||
|
||
# firmware settings | ||
cd_boot_firmware="bhyve" | ||
[ ${freebsdhostversion} -lt 1301510 ] && hdd_boot_firmware="refind" | ||
|
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
#!/bin/sh | ||
# save/export all jails settings-only as ~cbsd/jexport/XXX.img | ||
#v14.0.7 | ||
# Update global media databases from existance bhyves | ||
CBSD_APP="${0##*/}" | ||
: ${distdir="/usr/local/cbsd"} | ||
[ ! -r "${distdir}/subr/cbsdbootstrap.subr" ] && exit 1 | ||
. ${distdir}/subr/cbsdbootstrap.subr || exit 1 | ||
test_sql_stuff | ||
|
||
# | ||
. ${subrdir}/nc.subr | ||
readconf initenv.conf | ||
|
||
[ -z "${initenv_backup_bases}" -o "${initenv_backup_bases}" = "0" ] && exit 0 | ||
|
||
ALL_JAILS=$( cbsd jorder ) | ||
ALL_BHYVE=$( cbsd border ) | ||
ALL_QEMU=$( cbsd qorder ) | ||
ALL_XEN=$( cbsd xorder ) | ||
|
||
_total_env=0 | ||
_cur_env=1 | ||
for i in ${ALL_JAILS} ${ALL_BHYVE} ${ALL_QEMU} ${ALL_XEN}; do | ||
_total_env=$(( _total_env + 1 )) | ||
done | ||
|
||
[ ${_total_env} -eq 0 ] && exit 0 | ||
|
||
echo "${CBSD_APP} in progress ( can be disabled via ~cbsd/etc/initenv.conf ): initenv_backup_bases=${initenv_backup_bases}" | ||
DT=$( date "+%Y%m%d%H%M%S" ) | ||
|
||
for i in ${ALL_JAILS} ${ALL_BHYVE} ${ALL_QEMU} ${ALL_XEN}; do | ||
printf " * ${CBSD_APP}: [${_cur_env}/${_total_env}] exprort/backup settings for: ${i}" | ||
[ -r ${workdir}/jails-system/${i}/local.sqlite ] && ${CP_CMD} -a ${workdir}/jails-system/${i}/local.sqlite ${workdir}/jails-system/${i}/local.sqlite-${DT}.bkp | ||
#/usr/local/bin/cbsd jexport jname=${i} jexport_exclude="/" dstdir=${workdir}/jails-system/${i}/ >/dev/null 2>&1 | ||
|
||
# rotate | ||
DB_FILES=$( ${FIND_CMD} ${workdir}/jails-system/${i}/ -type f -depth 1 -maxdepth 1 -name "local.sqlite-*.bkp" | ${SORT_CMD} -n -r ) | ||
[ -z "${DB_FILES}" ] && echo && continue | ||
NUM=0 | ||
pruned=0 | ||
_prune_list= | ||
for j in ${DB_FILES}; do | ||
NUM=$(( NUM + 1 )); | ||
if [ ${NUM} -gt ${initenv_backup_bases} ]; then | ||
_prune_basename=$( ${BASENAME_CMD} ${j} ) | ||
_prune_list="${_prune_list} ${_prune_basename}" | ||
${RM_CMD} -rf ${j} | ||
pruned=1 | ||
fi | ||
done | ||
if [ ${pruned} -eq 1 ]; then | ||
echo " (prune:${_prune_list})" | ||
else | ||
echo | ||
fi | ||
_cur_env=$(( _cur_env + 1 )) | ||
done | ||
|
||
${CP_CMD} -a ~cbsd/var/db ~cbsd/var/db-${DT} | ||
|
||
# rotate | ||
DB_DIRS=$( ${FIND_CMD} ~cbsd/var/ -type d -depth 1 -maxdepth 1 -name "db-*" | ${SORT_CMD} -n -r ) | ||
|
||
NUM=0 | ||
for i in ${DB_DIRS}; do | ||
NUM=$(( NUM + 1 )); | ||
if [ ${NUM} -gt ${initenv_backup_bases} ]; then | ||
echo " * ${CBSD_APP}: prune old backup dirs: ${i}" | ||
${RM_CMD} -rf ${i} | ||
fi | ||
done | ||
|
||
exit 0 |