Backup : Disable auto-copy of hot media.

This commit is contained in:
Dmitry Voronin 2023-12-30 13:34:00 +03:00
parent 4136b532c7
commit 4ac00cee5b

View file

@ -9,10 +9,10 @@ source /var/roothome/.config/bash/module/recursive.sh
dow=$(/usr/bin/date +%u) # current day of week number.
date=$(/usr/bin/date +%Y%m%d%H%M) # date stamp.
path_src="/var/mnt/storage/hot" # backup src location.
path_media="/var/mnt/storage/cold_1/media /var/mnt/storage/cold_2/media" # media paths.
path_mount="/var/mnt/storage/cold_1" # backup mount location.
path_backup="${path_mount}/backup" # backup dir location.
path_docker="${path_backup}/home" # docker backup location.
path_media="/var/mnt/storage/cold_1/media /var/mnt/storage/cold_2/media" # media paths.
# Check if backup drive is mounted.
if [ ! -f "${path_mount}"/.mount ]; then
@ -36,23 +36,22 @@ shopt -s dotglob
builtin cd "${path_src}"
# Save media list.
/usr/bin/find ${path_media} -type d | gzip -1 > ${path_backup}/tmp/ColdMedia.txt.gz || notify 'Backup : Failed to save media list!'
/usr/bin/find ${path_media} -type d | gzip -1 > ${path_backup}/media/ColdMedia.txt.gz || notify 'Backup : Failed to save media list!'
# Backup docker.
rm ${path_docker}/${dow}_*.tgz
/usr/bin/tar --exclude-from=docker/.tarignore -c docker | /usr/bin/gzip -1 > ${path_docker}/docker.tgz && mv ${path_docker}/docker.tgz ${path_docker}/${dow}_${date}-$(/usr/bin/sha1sum ${path_docker}/docker.tgz | cut -d\ -f1).tgz || notify 'Backup : Failed to save docker!'
# Update checksums.
cd ${path_src}/media/book/ && recursive checksum_create || notify 'Backup : Checksum book failed!'
cd ${path_src}/media/music/ && recursive checksum_create || notify 'Backup : Checksum music failed!'
cd ${path_src}/media/paper/ && recursive checksum_create || notify 'Backup : Checksum paper failed!'
builtin cd ${path_src}/media/book/ && recursive checksum_create || notify 'Backup : Checksum book failed!'
builtin cd ${path_src}/media/music/ && recursive checksum_create || notify 'Backup : Checksum music failed!'
builtin cd ${path_src}/media/paper/ && recursive checksum_create || notify 'Backup : Checksum paper failed!'
# Copy tmp media.
/usr/bin/rsync -a --delete ${path_src}/media/book/ ${path_backup}/tmp/book/ || notify 'Backup : Failed to save books!'
/usr/bin/rsync -a --delete ${path_src}/media/music/ ${path_backup}/tmp/music/ || notify 'Backup : Failed to save music!'
/usr/bin/rsync -a --delete ${path_src}/media/paper/ ${path_backup}/tmp/paper/ || notify 'Backup : Failed to save paper!'
/usr/bin/rsync -a --delete ${path_src}/media/porn/ ${path_backup}/tmp/porn/ || notify 'Backup : Failed to save porn!'
/usr/bin/rsync -a --delete /var/mnt/storage/cold_2/media/youtube/best/ ${path_backup}/tmp/youtube/ || notify 'Backup : Failed to save youtube!'
# Copy tmp media. NOTE: Now I manually archive all of that.
# /usr/bin/rsync -a --delete ${path_src}/media/book/ ${path_backup}/tmp/book/ || notify 'Backup : Failed to save books!'
# /usr/bin/rsync -a --delete ${path_src}/media/music/ ${path_backup}/tmp/music/ || notify 'Backup : Failed to save music!'
# /usr/bin/rsync -a --delete ${path_src}/media/paper/ ${path_backup}/tmp/paper/ || notify 'Backup : Failed to save paper!'
# /usr/bin/rsync -a --delete ${path_src}/media/porn/ ${path_backup}/tmp/porn/ || notify 'Backup : Failed to save porn!'
# Upload external.
#/usr/bin/rsync -ahP -e 'ssh -p 143 -i /var/roothome/document/key/ssh/pi.key' /var/mnt/backup/ root@192.168.1.6:/var/mnt/backup/ || notify 'backup : failed upload'