backup : update to use cold_1.
This commit is contained in:
parent
76db8ea928
commit
7c464402f0
|
@ -10,54 +10,54 @@ dow=$(/usr/bin/date +%u) # curre
|
||||||
date=$(/usr/bin/date +%Y%m%d%H%M) # date stamp.
|
date=$(/usr/bin/date +%Y%m%d%H%M) # date stamp.
|
||||||
path_src="/var/mnt/storage/hot" # backup src location.
|
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_media="/var/mnt/storage/cold_1/media /var/mnt/storage/cold_2/media" # media paths.
|
||||||
path_mount="/var/mnt/backup" # backup mount location.
|
path_mount="/var/mnt/storage/cold_1" # backup mount location.
|
||||||
path_backup="$path_mount/backup" # backup dir location.
|
path_backup="${path_mount}/backup" # backup dir location.
|
||||||
path_docker="$path_backup/home" # docker backup location.
|
path_docker="${path_backup}/home" # docker backup location.
|
||||||
|
|
||||||
# check if backup drive is mounted.
|
# Check if backup drive is mounted.
|
||||||
if [ ! -f "$path_mount"/.mount ]; then
|
if [ ! -f "${path_mount}"/.mount ]; then
|
||||||
echo "backup : $path_mount not mounted"
|
echo "Backup : ${path_mount} not mounted!"
|
||||||
notify "backup : $path_mount not mounted"
|
notify "Backup : ${path_mount} not mounted!"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# check if hot storage is mounted.
|
# Check if hot storage is mounted.
|
||||||
if [ ! -f "$path_src"/.mount ]; then
|
if [ ! -f "${path_src}"/.mount ]; then
|
||||||
echo "backup : $path_src not mounted"
|
echo "Backup : ${path_src} not mounted!"
|
||||||
notify "backup : $path_src not mounted"
|
notify "Backup : ${path_src} not mounted!"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# tweak bash.
|
# Tweak bash.
|
||||||
shopt -s globstar
|
shopt -s globstar
|
||||||
shopt -s dotglob
|
shopt -s dotglob
|
||||||
|
|
||||||
# cd to src storage.
|
# Cd to src storage.
|
||||||
builtin cd "$path_src"
|
builtin cd "${path_src}"
|
||||||
|
|
||||||
# save media list.
|
# Save media list.
|
||||||
/usr/bin/find $path_media -type d | gzip -1 > ${path_backup}/tmp/ColdMedia.txt.gz || notify 'backup : save media list failed'
|
/usr/bin/find ${path_media} -type d | gzip -1 > ${path_backup}/tmp/ColdMedia.txt.gz || notify 'Backup : Failed to save media list!'
|
||||||
|
|
||||||
# backup docker.
|
# Backup docker.
|
||||||
rm $path_docker/${dow}_*.tgz
|
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 : docker failed'
|
/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.
|
# Update checksums.
|
||||||
cd /var/mnt/storage/hot/media/book/ && recursive checksum_create || notify 'Backup : checksum book failed.'
|
cd ${path_src}/media/book/ && recursive checksum_create || notify 'Backup : Checksum book failed!'
|
||||||
cd /var/mnt/storage/hot/media/music/ && recursive checksum_create || notify 'Backup : checksum music failed.'
|
cd ${path_src}/media/music/ && recursive checksum_create || notify 'Backup : Checksum music failed!'
|
||||||
cd /var/mnt/storage/hot/media/paper/ && recursive checksum_create || notify 'Backup : checksum paper failed.'
|
cd ${path_src}/media/paper/ && recursive checksum_create || notify 'Backup : Checksum paper failed!'
|
||||||
|
|
||||||
# copy media.
|
# Copy tmp media.
|
||||||
/usr/bin/rsync -a --delete /var/mnt/storage/hot/media/book/ /var/mnt/backup/backup/tmp/book/ || notify 'backup : copy book failed'
|
/usr/bin/rsync -a --delete ${path_src}/media/book/ ${path_backup}/tmp/book/ || notify 'Backup : Failed to save books!'
|
||||||
/usr/bin/rsync -a --delete /var/mnt/storage/hot/media/music/ /var/mnt/backup/backup/tmp/music/ || notify 'backup : copy music failed'
|
/usr/bin/rsync -a --delete ${path_src}/media/music/ ${path_backup}/tmp/music/ || notify 'Backup : Failed to save music!'
|
||||||
/usr/bin/rsync -a --delete /var/mnt/storage/hot/media/paper/ /var/mnt/backup/backup/tmp/paper/ || notify 'backup : copy paper failed'
|
/usr/bin/rsync -a --delete ${path_src}/media/paper/ ${path_backup}/tmp/paper/ || notify 'Backup : Failed to save paper!'
|
||||||
/usr/bin/rsync -a --delete /var/mnt/storage/hot/media/porn/ /var/mnt/backup/backup/tmp/porn/ || notify 'backup : copy porn failed'
|
/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/ /var/mnt/backup/backup/tmp/youtube/ || notify 'backup : copy youtube failed'
|
/usr/bin/rsync -a --delete /var/mnt/storage/cold_2/media/youtube/best/ ${path_backup}/tmp/youtube/ || notify 'Backup : Failed to save youtube!'
|
||||||
|
|
||||||
# upload external.
|
# 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'
|
#/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'
|
||||||
|
|
||||||
# notify completion & size.
|
# Notify completion & size.
|
||||||
bupsize=$(/usr/bin/du -h $path_docker/${dow}_*.tgz | awk '{print $1}')
|
bupsize=$(/usr/bin/du -h ${path_docker}/${dow}_*.tgz | awk '{print $1}')
|
||||||
notify_silent "backup : complete : $bupsize"
|
notify_silent "Backup : Complete ${bupsize}."
|
||||||
echo "backup : complete : $bupsize"
|
echo "Backup : Complete ${bupsize}."
|
||||||
|
|
Reference in a new issue