This commit is contained in:
Your Name 2022-12-19 10:57:03 -07:00
parent 19fd59584c
commit 84839b68ee

View File

@ -33,7 +33,11 @@ EFI="/dev/$(lsblk | grep $HARD_DISK | head -2 | tail -1 | cut -c 7-20 | cut -d '
BTRFS="/dev/$(lsblk | grep $HARD_DISK | head -4 | tail -1 | cut -c 7-20 | cut -d ' ' -f1)"
BOOT="/dev/$(lsblk | grep $HARD_DISK | head -3 | tail -1 | cut -c 7-20 | cut -d ' ' -f1)"
ROOT_NAME='debian'
USB_BACKUP='/dev/disk/by-uuid/1a143f83-d4fe-4894-8e67-2b6d3baacea6'
#NET_BACKUP='-t cifs -o username=guest,password=123456 //192.168.0.153/backup'
#HOME_BACKUP="root@server2:/raid/backup/home/"
NET_BACKUP='/dev/disk/by-uuid/1a143f83-d4fe-4894-8e67-2b6d3baacea6'
HOME_BACKUP="$TARGET/home/"
######################################
USER="verita84"
USER_PASSWORD="123456"
@ -47,7 +51,7 @@ DEBIAN_RELEASE='testing'
FLATPAKS+=( app/net.brinkervii.grapejuice org.kde.kdenlive )
#Packages
SHARED_DESKTOP_APPS=" gnome-core gimp gnome-tweaks gajim evolution nextcloud-desktop telegram-desktop gnome-photos handbrake mpv libreoffice "
SHARED_DESKTOP_APPS=" gnome-music gnome-core gimp gnome-tweaks gajim evolution nextcloud-desktop telegram-desktop gnome-photos handbrake mpv libreoffice "
PACKAGES=" apt-transport-https zram-tools samba samba-common nfs-common nfs-kernel-server linux-cpupower locales syncthing redis cockpit cockpit-machines cockpit-podman flatpak powertop blueman cups acpi packagekit cockpit-packagekit cockpit-pcp cockpit-storaged acpid podman pulseaudio ghostscript cifs-utils ntp vim-airline rsync screen base udev git network-manager efibootmgr linux-headers-amd64 cryptsetup network-manager-openvpn ntp screen docbook-xsl alsa-utils sysstat postgresql redis neofetch fuse3 build-essential unzip bash-completion parted dosfstools wget curl "
#REMOVED=" yt-dlp aardvark-dns podman-compose systemd-zram-generator podman-toolbox "
VIRTUALIZATION=" virt-manager qemu-system libvirt-daemon-system ovmf "
@ -59,70 +63,42 @@ auto_login(){
sed -i "/True/a AutomaticLogin=$USER" $TARGET/etc/gdm3/daemon.conf
}
clean-old-usb-snapshots(){
echo;echo "[Cleaning up old USB snapshots.....]";echo
btrfs sub delete $TARGET/$ROOT_NAME-$1
echo;echo "[Cleaning up old EFI data.....]";echo
rm -rf $TARGET/efi-$1
}
clean-old-snapshots() {
echo;echo "[Cleaning up old snapshots.....]";echo
btrfs sub delete /.snapshots/$ROOT_NAME-$1
}
create-usb-snapshots(){
create-smb-snapshots(){
echo;echo "[Creating new snapshots.....]";echo
btrfs sub snap -r / /.snapshots/$ROOT_NAME-$1
}
send-snapshots(){
echo;echo "[Sending snapshot to $USB_BACKUP]";echo
btrfs send /.snapshots/$ROOT_NAME-$1 | btrfs receive $TARGET
}
copy-efi-to-usb(){
echo;echo "[Copying EFI data....]";echo
mkdir $TARGET/efi-$1
mkdir $TARGET/$1
cp -rf /boot/* $TARGET/efi-$1/
time tar cvpf $TARGET/$ROOT_NAME-$1.tgz --exclude=/mnt/* --exclude=/var/tmp/* --exclude=/tmp/* --exclude=/raid/* --exclude=/root/* --exclude=/var/cache/apt/archives/* --exclude=/proc/* --exclude=/.snapshots/* --exclude=$TARGET/* --exclude=/var/lib/libvirt/* --exclude=/dev/* --exclude=/sys/* --exclude=/home/* --exclude=/var/lib/postgresql --exclude=/var/lib/containers /
}
homeBackup() {
echo;echo "[Copying USER data....]";echo
rsync -av --delete /home/ $TARGET/home/
rsync --progress -avz --delete /home/ --exclude=.cache --exclude=.local/share/containers $HOME_BACKUP
}
usb-backup() {
net-backup() {
umount $TARGET
echo;echo "[Mounting $USB_BACKUP]";echo
mount $USB_BACKUP $TARGET
echo;echo "[Mounting.....]";echo
mount $NET_BACKUP $TARGET
mkdir $TARGET/$1
if [ "$2" = "home" ]; then
homeBackup
fi
clean-old-snapshots "$1"
clean-old-usb-snapshots "$1"
create-usb-snapshots "$1"
send-snapshots "$1"
clean-old-snapshots "$1"
copy-efi-to-usb "$1"
cp -f /usr/bin/debian.sh $TARGET/$1
create-smb-snapshots "$1"
cp -f debian.sh $TARGET/$1/
ls $TARGET/
umount $TARGET
}
usb-restore() {
net-restore() {
partitions
rsync -av ../$ROOT_NAME-$2/ $TARGET/ --exclude=/home --delete
rm -rf $TARGET/usr $TARGET/sbin $TARGET/lib32 $TARGET/libx32 $TARGET/lib $TARGET/vmlinuz* $TARGET/initrd* $TARGET/bin $TARGET/var $TARGET/root $TARGET/opt $TARGET/etc $TARGET/run
tar xfpv ../$ROOT_NAME-$2.tgz -C $TARGET/
if [ "$2" = "home" ]; then
rsync -av --delete ../home/ $TARGET/home/
rsync -av --progress --delete $HOME_BACKUP $TARGET/home/
fi
cp -rf ../efi-$2/* $TARGET/boot/
fstab
cp -f debian.sh $TARGET/
systemMounts
@ -172,7 +148,6 @@ install() {
unmount
}
desktop(){
systemctl disable --now exim4
systemctl disable --now cockpit.socket
@ -441,13 +416,13 @@ elif [ "$1" = "bootloader" ]; then
elif [ "$1" = "snapshot" ]; then
snapshots
elif [ "$1" = "backup" ]; then
usb-backup "$2" "$3"
net-backup "$2" "$3"
elif [ "$1" = "grub-snapshots" ]; then
grub-snapshots
elif [ "$1" = "btrfs-tweaks" ]; then
btrfs-tweaks
elif [ "$1" = "restore" ]; then
usb-restore "$2" "$3"
net-restore "$2" "$3"
elif [ "$1" = "remove-snapshot" ]; then
remove-snapshots
elif [ "$1" = "help" ]; then