This commit is contained in:
Dym Sohin 2024-02-24 16:33:16 +01:00
commit 3789c7095c
6 changed files with 272 additions and 0 deletions

39
current.sh Executable file
View File

@ -0,0 +1,39 @@
#!/usr/bin/env zsh
BAK="/home/dym/Servers/self-files"
if [ ! -z "$1" ]; then
BAK="$1"
fi
cd `realpath "$0" | xargs dirname`
./bak-home.sh "$BAK/Home_bak"
cp /home/dym/.config/doublecmd/doublecmd.xml \
/Cfg/doublecmd/
DIRS=(
Apps
Cfg
)
for DIR in "${DIRS[@]}"; do
echo "-
-
# '/$DIR'"
sudo \
rsync -zrhP --links --size-only --verbose --delete \
--exclude '**/.Trash-1000' \
--exclude '**/__sapper__/' \
--exclude '**/node_modules/' \
--exclude '**/target/' \
"/$DIR/" \
"$BAK/${DIR}_bak"
done
echo "-
-
# '~/.privat'"
sudo \
rsync -zrhP --links --size-only --verbose --delete \
"/home/dym/.privat/" \
"$BAK/.privat_bak"

81
current_to_archive.sh Executable file
View File

@ -0,0 +1,81 @@
#!/usr/bin/env zsh
BAK="/Data/_bak"
# restic init '/Servers/self/.privat' \
# -p '/Servers/self/.privat/restic/p.txt' \
# -r "$BAK/.privat_bak"
restic backup '/Servers/self/.privat' \
-p '/Servers/self/.privat/restic/p.txt' \
-r "$BAK/.privat_bak"
cd `realpath "$0" | xargs dirname`
./home.sh "$BAK/Home_m20"
sudo \
rsync -zrhP --links --size-only --verbose --delete \
--exclude '**/.Trash-1000' \
--exclude '**/__sapper__/' \
--exclude '**/node_modules/' \
--exclude '**/target/' \
"/Servers/self/My/" \
"/Data/_my"
sudo \
rsync -zrhP --links --size-only --verbose --delete \
--exclude '**/.Trash-1000' \
--exclude '**/__sapper__/' \
--exclude '**/node_modules/' \
--exclude '**/target/' \
"/Work/" \
"/Data/_work/self"
DIRS=(
Books
Code
Img
Music
Ui
Forks
Fonts
# Work
)
for DIR in "${DIRS[@]}"; do
echo "-
-
# '$DIR'"
sudo \
rsync -zrhP --links --size-only --verbose --delete \
--exclude '**/.Trash-1000' \
--exclude '**/__sapper__/' \
--exclude '**/node_modules/' \
--exclude '**/target/' \
"/Servers/self/$DIR/" \
"$BAK/${DIR}"
done
DIRS=(
Cfg
)
for DIR in "${DIRS[@]}"; do
echo "-
-
# '$DIR'"
sudo \
rsync -zrhP --links --size-only --verbose --delete \
--exclude '**/.Trash-1000' \
"/$DIR/" \
"$BAK/${DIR}"
done
# sudo \
# rsync -zrhP --links --size-only --verbose --delete \
# "/var/lib/docker/" \
# "$BAK/var_lib_docker"

34
data.sh Executable file
View File

@ -0,0 +1,34 @@
#!/usr/bin/env zsh
BAK="/media/data_bak"
if [ ! -z "$1" ]; then
BAK="$1"
fi
DIRS=(
Apps_andr
Apps_deb
Apps_wnd
Audio
Books
Bugs
Code
Drivers
Fonts
Img
Iso
Music
Posts
Texts
Video
)
for DIR in "${DIRS[@]}"; do
echo "-
-
# '$DIR'"
sudo \
rsync -zrhP --links --size-only --verbose --delete \
--exclude '**/.Trash-1000' \
"/Data/${DIR}/" \
"$BAK/${DIR}"
done

80
home.sh Executable file
View File

@ -0,0 +1,80 @@
#!/usr/bin/env zsh
# home.sh
BAK='/Data/_bak/Home_nix'
if [ ! -z "$1" ]; then
BAK="$1"
fi
echo "BAK: backing up '$HOME' to '$BAK'"
rsync -rhP --links --size-only --verbose --delete \
--exclude '**/.Trash-1000/' \
--exclude '**/*.log' \
--exclude '**/*.part' \
--exclude '**/*~' \
--exclude '**/hyphen-data/' \
--exclude '**/logs/' \
--exclude '**/node_modules/' \
--exclude '**/storage/default/' \
--exclude '**/datareporting/' \
--exclude '.android/' \
--exclude '.bun/' \
--exclude '.cabal/' \
--exclude '.cache/' \
--exclude '.cargo/' \
--exclude '.cinnamon/' \
--exclude '.config/agregore-browser/' \
--exclude '.config/chromium/' \
--exclude '.config/Code/Cache*' \
--exclude '.config/Code/Crashpad/' \
--exclude '.config/Code/Service Worker/' \
--exclude '.config/Code/User/History/' \
--exclude '.config/Code/User/workspaceStorage/' \
--exclude '.config/google-chrome-unstable/' \
--exclude '.config/google-chrome/' \
--exclude '.config/vivaldi/' \
--exclude '.config/xnviewmp/' \
--exclude '.deno/' \
--exclude '.docker/' \
--exclude '.electron-gyp/' \
--exclude '.figma/' \
--exclude '.fonts/' \
--exclude '.gnome/' \
--exclude '.gnupg/' \
--exclude '.gphoto/' \
--exclude '.gradle/' \
--exclude '.java/' \
--exclude '.linuxmint/' \
--exclude '.local/share/lutris' \
--exclude '.local/share/Trash' \
--exclude '.nix-defexpr' \
--exclude '.nix-profile' \
--exclude '.node/' \
--exclude '.npm/' \
--exclude '.nv/' \
--exclude '.pipupgrade/' \
--exclude '.pki/' \
--exclude '.privat/' \
--exclude '.Private/' \
--exclude '.pub-cache/' \
--exclude '.rustup/' \
--exclude '.ssh' \
--exclude '.steam*' \
--exclude '.thunderbird' \
--exclude '.zoom/' \
--exclude 'Android/' \
--exclude 'FontBase/' \
--exclude 'Games/' \
--exclude 'Cfg/' \
--exclude 'Desktop/' \
--exclude 'Inbox/' \
--exclude 'My Games/' \
--exclude 'go/' \
--exclude 'Private/' \
--exclude 'snap/' \
--exclude 'Steam/' \
--exclude 'Servers/' \
--exclude 'tmp/' \
"/home/dym/" \
"$BAK"

24
pg-export.sh Executable file
View File

@ -0,0 +1,24 @@
#!/usr/bin/env zsh
PG_C="pg_dump -U postgres -Z0 -j 4 -Fd"
DATE=`date +%Y%m%d`
rm -rf "/bak/db_current"
mkdir -p "/bak/db_current/"
mkdir -p "/bak/db-$DATE/"
chown -R postgres:postgres "/bak/db_current"
chmod g+s -R "/bak/db_current"
DB_TABLES=(
forgejo
inventory
gts
)
for DB_TABLE in $DB_TABLES ; do
echo "exporting $DB_TABLE"
su - postgres -c "$PG_C $DB_TABLE -f /bak/db_current/$DB_TABLE/" \
&& echo "compacting $DB_TABLE" \
&& tar -zcvf "/bak/db-$DATE/$DB_TABLE.tgz" \
"/bak/db_current/$DB_TABLE/"
done

14
server_to_archive.sh Executable file
View File

@ -0,0 +1,14 @@
#!/bin/sh
BAK="/Data/_server"
rsync -zrhP --links --size-only --verbose --delete \
"/Servers/infra/var/www/" \
"$BAK/infra-www"
rsync -zrhP --links --size-only --verbose --delete \
"/Servers/infra/var/lib/docker/volumes/" \
"$BAK/docker-volumes"