Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Production and Testing and backup on same PC
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
C5ace
Guru
Guru


Joined: 23 Dec 2013
Posts: 472
Location: Brisbane, Australia

PostPosted: Thu Feb 02, 2023 3:41 am    Post subject: Production and Testing and backup on same PC Reply with quote

I have 2 copies of Gentoo on my desktop pc. One production copy on a RAID 5 array and one testing/development copy on a single drive. The testing copy is updated each time I update the production copy. Kernel upgrades are done manually with "genkernel all". The production copy boots automatically on power on. The testing copy boots when selected from BIOS. Partitions and are MBR. File system are EXT4. Bootloaders are Grub2. Hard drives installed are 2TB each.

The main purpose of the testing copy is to test changed configuration and applications.

To update the testing copy from the production copy I run "PT" shell script. To update the production copy from the testing copy I run TP shell script.

PT shell script /opt/bin/PD
Code:
#!/bin/sh

echo "P_to_T"

time /usr/bin/rsync -c -r -t -p -o -g -x -v --progress --delete -l -H -D -i -s --exclude=/boot/grub/* --exclude=/dev/* --exclude=/etc/default/grub --exclude=/etc/fstab --exclude=/etc/genkernel.conf --exclude=/home/* --include=/media/.keep --exclude=/media/* --include=/proc/.keep --exclude=/proc/* --include=/run/.keep --exclude=/run/* --include=/sys/.keep --exclude=/sys/* --include=/tmp/.keep --exclude=/tmp/* --include=/var/tmp/.keep --exclude=/var/tmp/* --exclude=/root/.cache/*  --include=/var/cache/.keep --exclude=/var/cache/distfiles/* --include=/var/cache/distfiles/.keep --exclude=/var/db/repos/gentoo/* --exclude=/var/db/repos/localrepo/* --exclude=/mnt/* --exclude=/VirtualBox/* --exclude=/T_ROOT --exclude=/P_ROOT --exclude=/boot/T_BOOT --exclude=/boot/P_BOOT --exclude=/home/T_HOME --exclude=/home/P_HOME --exclude=/VirtualBox/T_VBOX --exclude=/VirtualBox/P_VBOX / /mnt/d_root/ | tee /var/log/P_ROOT_to_T_ROOT.log

time /usr/bin/rsync -c -r -t -p -o -g -x -v --progress --delete -l -H -D -i -s --exclude=/boot/  --exclude=/T_HOME --exclude=/P_HOME /home/ /mnt/t_root/home/ | tee /var/log /J_HOME_to_D_HOME.log


Production fstab (/etc/fstab)
Code:
# <fs>      <mountpoint>      <type>   <opts>   <dump/pass>
LABEL=J_BOOT    /boot         ext4   defaults 0 2
LABEL=J_ROOT   /         ext4   defaults 0 1
LABEL=J_SWAP    none         swap   sw       0 0
LABEL=J_HOME    /home         ext4   defaults 0 2
LABEL=J_VBOX   /VirtualBox      ext4   defaults 0 2

LABEL=T_ROOT    /mnt/t_root      ext4    defaults 0 2
LABEL=T_BOOT    /mnt/t_root/boot   ext4    defaults 0 2
LABEL=T_HOME    /mnt/t_root/home   ext4    defaults 0 2
LABEL=T_VBOX    /mnt/t_root/VirtualBox   ext4    defaults 0 2

192.168.0.105:/repos     /var/db/repos/       nfs rw,_netdev 0 0
192.168.0.105:/distfiles /var/cache/distfiles nfs rw,_netdev 0 0


Production genkernel.conf (/etc/genkernel.conf)
Code:
.
.
.
# =========MISC BOOT CONFIGURATION============
#
# Specify a default for real_root=
#REAL_ROOT="/dev/one/two/gentoo"

MENUCONFIG="yes"
# CLEAN="no"
# MRPROPER="no"
MAKEOPTS="-j32"
MDADM="yes"
MDADM_CONFIG="/etc/mdadm.conf"
DISKLABEL="yes"
KERNEL_FILENAME="vmlinuz-%%KV%%-P_ROOT"
INITRAMFS_FILENAME="initramfs-%%KV%%-P_ROOT.img"


Production grub (/etc/default/grub)
Code:
.
.
.
GRUB_DISTRIBUTOR="P_Gentoo"

# Default menu entry
#GRUB_DEFAULT=0

# Boot the default entry this many seconds after the menu is displayed
GRUB_TIMEOUT=15
#GRUB_TIMEOUT_STYLE=menu

# Append parameters to the linux kernel command line
GRUB_CMDLINE_LINUX="root=/dev/ram0 domdadm rootfstype=ext4 real_root=LABEL=P_ROOT scandelay=5 ro net.ifnames=0 delayacct"
#
# Examples:
.
.
.



From Testing to Production

TP shell script /opt/bin/TP
Code:
#!/bin/sh

echo "T_to_P"

time /usr/bin/rsync -c -r -t -p -o -g -x -v --progress --delete -l -H -D -i -s --exclude=/boot/grub/* --exclude=/dev/* --exclude=/etc/default/grub --exclude=/etc/fstab --exclude=/etc/genkernel.conf --exclude=/home/* --include=/media/.keep --exclude=/media/* --include=/proc/.keep --exclude=/proc/* --include=/run/.keep --exclude=/run/* --include=/sys/.keep --exclude=/sys/* --include=/tmp/.keep --exclude=/tmp/* --include=/var/tmp/.keep --exclude=/var/tmp/* --exclude=/root/.cache/*  --include=/var/cache/.keep --exclude=/var/cache/distfiles/* --include=/var/cache/distfiles/.keep --exclude=/var/db/repos/gentoo/* --exclude=/var/db/repos/localrepo/* --exclude=/mnt/* --exclude=/VirtualBox/* --exclude=/P_ROOT --exclude=/P_ROOT --exclude=/boot/P_BOOT --exclude=/boot/T_BOOT --exclude=/home/P_HOME --exclude=/home/T_HOME --exclude=/VirtualBox/P_VBOX --exclude=/VirtualBox/T_VBOX / /mnt/p_root/ | tee /var/log/T_ROOT_to_P_ROOT.log

time /usr/bin/rsync -c -r -t -p -o -g -x -v --progress --delete -l -H -D -i -s --exclude=/boot/  --exclude=/P_HOME --exclude=/T_HOME /home/ /mnt/p_root/home/ | tee /var/log /T_HOME_to_P_HOME.log


Testing fstab (/etc/fstab)
Code:
#
#<fs>           <mountpoint>    <type>  <opts>          <dump/pass>
LABEL=T_BOOT   /boot           ext4    defaults   0 2
LABEL=T_ROOT   /      ext4    defaults   0 2
LABEL=T_HOME   /home      ext4    defaults   0 2
LABEL=T_VBOX   /VirtualBox   ext4    defaults   0 2
LABEL=T_SWAP    none            swap    sw              0 0
/dev/cdrom      /mnt/cdrom      auto    noauto,ro       0 0

LABEL=P_ROOT    /mnt/j_root      ext4    defaults 0 2
LABEL=P_BOOT    /mnt/j_root/boot   ext4    defaults 0 2
LABEL=P_HOME    /mnt/j_root/home   ext4    defaults 0 2
LABEL=P_VBOX    /mnt/j_root/VirtualBox   ext4    defaults 0 2

192.168.0.105:/repos     /var/db/repos/       nfs rw,_netdev 0 0
192.168.0.105:/distfiles /var/cache/distfiles nfs rw,_netdev 0 0



Testing genkernel.conf (/etc/genkernel.conf)
Code:
.
.
.
# =========MISC BOOT CONFIGURATION============
#
# Specify a default for real_root=
#REAL_ROOT="/dev/one/two/gentoo"

MENUCONFIG="yes"
CLEAN="no"
#MRPROPER="no"
MAKEOPTS="-j32"
MDADM="yes"
MDADM_CONFIG="/etc/mdadm.conf"
DISKLABEL="yes"
KERNEL_FILENAME="vmlinuz-%%KV%%-T_ROOT"
INITRAMFS_FILENAME="initramfs-%%KV%%-T_ROOT.img"



Testing grub (/etc/default/grub)
Code:
.
.
.
GRUB_DISTRIBUTOR="T_Gentoo"

# Default menu entry
#GRUB_DEFAULT=0

# Boot the default entry this many seconds after the menu is displayed
GRUB_TIMEOUT=15
#GRUB_TIMEOUT_STYLE=menu

# Append parameters to the linux kernel command line
GRUB_CMDLINE_LINUX="root=/dev/ram0 domdadm rootfstype=ext4 real_root=LABEL=T_ROOT scandelay=5 ro net.ifnames=0 delayacct"
#
# Examples:
.
.
.


Warning! There may be typos and transcription errors.

To speed up transfers delete the "-c" option from the rsync commands.
_________________
Observation after 30 years working with computers:
All software has known and unknown bugs and vulnerabilities. Especially software written in complex, unstable and object oriented languages such as perl, python, C++, C#, Rust and the likes.
Back to top
View user's profile Send private message
psycho
Guru
Guru


Joined: 22 Jun 2007
Posts: 534
Location: New Zealand

PostPosted: Wed Feb 22, 2023 9:56 am    Post subject: Reply with quote

Hi C5ace.

I do things similarly, never updating systems in use, instead keeping testing systems slightly ahead of them, only copying the updates over once they've been tested systematically and everything important is demonstrably working properly. It takes a bit more effort (mostly in the form of the testing, some of which I haven't got around to automating, and some of which can't really be automated), but has completely eliminated nasty surprises when things need to work... so far at least. Ironically it means that my production systems often wind up being the ones on which I test new software (rather than updates), in the nothing-matters-now time just before copying a tested updated system over them.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum