Backup-Script
Bash
#!/bin/bash
echo "############################################"
echo "############################################"
echo "# Backup-Script #"
echo "# Author: tk1908 #"
echo "# E-Mail: tk1908@tkbrew.net #"
echo "# #"
echo "############################################"
echo "############################################"
OS=$(uname)
echo OS=$(uname)
# ROOTPATH für Darwin vorerst im HOME, hier muss noch debuggt werden. Ordner-Erstellung unter Volumes schlägt scheinbar fehl.
case $OS in
Linux)
ROOTPATH="/mnt"
;;
Darwin)
ROOTPATH="${HOME}/Test"
;;
esac
echo Funktionsaufruf
HOSTS=(krypton keppler tesla)
SHARES=( $(showmount -e keppler | awk '{print $1}' | sed '1d' | sed 's/^\(\/.*\)\/\(.*\)$/\2/') )
# Shareliste wird von keppler abgerufen. So ist sichergestellt, dass alle Shares erfasst werden.
for HOST in "${HOSTS[@]}"; do sudo mkdir $ROOTPATH/$HOST; for SHARE in "${SHARES[@]}";do sudo mkdir $ROOTPATH/$HOST/$SHARE; done; done
#tier2_Backup
function tier3_Backup () {
echo "Migrate Data from keppler to tesla"
echo "Creating Directorystructure an mounting shares"
for SHARE in "${SHARES[@]}"; do sudo mount ${HOSTS[2]}:/mnt/${HOSTS[2]}/$SHARE $ROOTPATH/${HOSTS[2]}/$SHARE; done
for SHARE in "${SHARES[@]}"; do sudo mount ${HOSTS[3]}:/mnt/xenon01/$SHARE $ROOTPATH/${HOSTS[3]}/$SHARE; done # Vorsicht Array in tesla heißt immernoch xenon01. Muss noch geändert werden!
rsync -rvu --exclude '#recycle' $ROOTPATH/${HOSTS[2]}/applications/ $ROOTPATH/${HOSTS[3]}/applications
rsync -rvu --exclude '#recycle' $ROOTPATH/${HOSTS[2]}/documents/ $ROOTPATH/${HOSTS[3]}/documents
rsync -rvu --exclude '#recycle' $ROOTPATH/${HOSTS[2]}/games/ $ROOTPATH/${HOSTS[3]}/games
rsync -rvu --exclude '#recycle' $ROOTPATH/${HOSTS[2]}/hoerspiele/ $ROOTPATH/${HOSTS[3]}/hoerspiele
rsync -rvu --exclude '#recycle' $ROOTPATH/${HOSTS[2]}/misc/ $ROOTPATH/${HOSTS[3]}/misc
rsync -rvu --exclude '#recycle' $ROOTPATH/${HOSTS[2]}/music/ $ROOTPATH/${HOSTS[3]}/music
rsync -rvu --exclude '#recycle' $ROOTPATH/${HOSTS[2]}/archive/porn/ $ROOTPATH/${HOSTS[3]}/porn
rsync -rvu --exclude '#recycle' $ROOTPATH/${HOSTS[2]}/videos/ $ROOTPATH/${HOSTS[3]}/videos
sudo umount /mnt/${HOSTS[2]}/*
sudo umount /mnt/${HOSTS[3]}/*
}
tier3_Backup
echo cleaning
sudo umount $SOURCEMOUNTPATH
sudo umount $TARGETMOUNTPATH
sudo rm -rf /mnt/*
Alles anzeigen
Ausgabe
Code
❯ /home/tkoehler/Git/Projekte/Home/Scripts/Unix-Shell/Backup
############################################
############################################
# Backup-Script #
# Author: tk1908 #
# E-Mail: tk1908@tkbrew.net #
# #
############################################
############################################
OS=Linux
Funktionsaufruf
mkdir: cannot create directory ‘/mnt/krypton’: File exists
mkdir: cannot create directory ‘/mnt/krypton/wsusoffline’: File exists
mkdir: cannot create directory ‘/mnt/krypton/videos’: File exists
mkdir: cannot create directory ‘/mnt/krypton/music’: File exists
mkdir: cannot create directory ‘/mnt/krypton/hoerspiele’: File exists
mkdir: cannot create directory ‘/mnt/krypton/games’: File exists
mkdir: cannot create directory ‘/mnt/krypton/backups’: File exists
mkdir: cannot create directory ‘/mnt/krypton/archive’: File exists
mkdir: cannot create directory ‘/mnt/krypton/pictures’: File exists
mkdir: cannot create directory ‘/mnt/krypton/misc’: File exists
mkdir: cannot create directory ‘/mnt/krypton/documents’: File exists
mkdir: cannot create directory ‘/mnt/krypton/applications’: File exists
mkdir: cannot create directory ‘/mnt/keppler’: File exists
mkdir: cannot create directory ‘/mnt/keppler/wsusoffline’: File exists
mkdir: cannot create directory ‘/mnt/keppler/videos’: File exists
mkdir: cannot create directory ‘/mnt/keppler/music’: File exists
mkdir: cannot create directory ‘/mnt/keppler/hoerspiele’: File exists
mkdir: cannot create directory ‘/mnt/keppler/games’: File exists
mkdir: cannot create directory ‘/mnt/keppler/backups’: File exists
mkdir: cannot create directory ‘/mnt/keppler/archive’: File exists
mkdir: cannot create directory ‘/mnt/keppler/pictures’: File exists
mkdir: cannot create directory ‘/mnt/keppler/misc’: File exists
mkdir: cannot create directory ‘/mnt/keppler/documents’: File exists
mkdir: cannot create directory ‘/mnt/keppler/applications’: File exists
mkdir: cannot create directory ‘/mnt/tesla’: File exists
mkdir: cannot create directory ‘/mnt/tesla/wsusoffline’: File exists
mkdir: cannot create directory ‘/mnt/tesla/videos’: File exists
mkdir: cannot create directory ‘/mnt/tesla/music’: File exists
mkdir: cannot create directory ‘/mnt/tesla/hoerspiele’: File exists
mkdir: cannot create directory ‘/mnt/tesla/games’: File exists
mkdir: cannot create directory ‘/mnt/tesla/backups’: File exists
mkdir: cannot create directory ‘/mnt/tesla/archive’: File exists
mkdir: cannot create directory ‘/mnt/tesla/pictures’: File exists
mkdir: cannot create directory ‘/mnt/tesla/misc’: File exists
mkdir: cannot create directory ‘/mnt/tesla/documents’: File exists
mkdir: cannot create directory ‘/mnt/tesla/applications’: File exists
Migrate Data from keppler to tesla
Creating Directorystructure an mounting shares
mount.nfs: Protocol not supported
mount.nfs: Protocol not supported
mount.nfs: Protocol not supported
mount.nfs: Protocol not supported
mount.nfs: Protocol not supported
mount.nfs: Protocol not supported
mount.nfs: Protocol not supported
mount.nfs: Protocol not supported
mount.nfs: Protocol not supported
mount.nfs: Protocol not supported
mount.nfs: Protocol not supported
mount.nfs: mount point /mnt//wsusoffline does not exist
mount.nfs: mount point /mnt//videos does not exist
mount.nfs: mount point /mnt//music does not exist
mount.nfs: mount point /mnt//hoerspiele does not exist
mount.nfs: mount point /mnt//games does not exist
mount.nfs: mount point /mnt//backups does not exist
mount.nfs: mount point /mnt//archive does not exist
mount.nfs: mount point /mnt//pictures does not exist
mount.nfs: mount point /mnt//misc does not exist
mount.nfs: mount point /mnt//documents does not exist
mount.nfs: mount point /mnt//applications does not exist
sending incremental file list
rsync: [generator] recv_generator: mkdir "/mnt/applications" failed: Permission denied (13)
*** Skipping any contents from this failed directory ***
./
sent 42 bytes received 19 bytes 122.00 bytes/sec
total size is 0 speedup is 0.00
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1330) [sender=v3.2.3]
sending incremental file list
rsync: [generator] recv_generator: mkdir "/mnt/documents" failed: Permission denied (13)
*** Skipping any contents from this failed directory ***
./
sent 42 bytes received 19 bytes 122.00 bytes/sec
total size is 0 speedup is 0.00
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1330) [sender=v3.2.3]
sending incremental file list
rsync: [generator] recv_generator: mkdir "/mnt/games" failed: Permission denied (13)
*** Skipping any contents from this failed directory ***
./
sent 42 bytes received 19 bytes 122.00 bytes/sec
total size is 0 speedup is 0.00
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1330) [sender=v3.2.3]
sending incremental file list
rsync: [generator] recv_generator: mkdir "/mnt/hoerspiele" failed: Permission denied (13)
*** Skipping any contents from this failed directory ***
./
sent 42 bytes received 19 bytes 122.00 bytes/sec
total size is 0 speedup is 0.00
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1330) [sender=v3.2.3]
sending incremental file list
rsync: [generator] recv_generator: mkdir "/mnt/misc" failed: Permission denied (13)
*** Skipping any contents from this failed directory ***
./
sent 42 bytes received 19 bytes 122.00 bytes/sec
total size is 0 speedup is 0.00
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1330) [sender=v3.2.3]
sending incremental file list
rsync: [generator] recv_generator: mkdir "/mnt/music" failed: Permission denied (13)
*** Skipping any contents from this failed directory ***
./
sent 42 bytes received 19 bytes 122.00 bytes/sec
total size is 0 speedup is 0.00
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1330) [sender=v3.2.3]
sending incremental file list
rsync: [sender] change_dir "/mnt/tesla/archive/porn" failed: No such file or directory (2)
sent 19 bytes received 12 bytes 62.00 bytes/sec
total size is 0 speedup is 0.00
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1330) [sender=v3.2.3]
sending incremental file list
rsync: [generator] recv_generator: mkdir "/mnt/videos" failed: Permission denied (13)
*** Skipping any contents from this failed directory ***
./
sent 42 bytes received 19 bytes 122.00 bytes/sec
total size is 0 speedup is 0.00
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1330) [sender=v3.2.3]
umount: /mnt/tesla/applications: not mounted.
umount: /mnt/tesla/archive: not mounted.
umount: /mnt/tesla/backups: not mounted.
umount: /mnt/tesla/documents: not mounted.
umount: /mnt/tesla/games: not mounted.
umount: /mnt/tesla/hoerspiele: not mounted.
umount: /mnt/tesla/misc: not mounted.
umount: /mnt/tesla/music: not mounted.
umount: /mnt/tesla/pictures: not mounted.
umount: /mnt/tesla/videos: not mounted.
umount: /mnt/tesla/wsusoffline: not mounted.
umount: /mnt//keppler: not mounted.
umount: /mnt//krypton: not mounted.
umount: /mnt//tesla: not mounted.
cleaning
umount: bad usage
Try 'umount --help' for more information.
umount: bad usage
Try 'umount --help' for more information.
/mnt
Alles anzeigen
Irgendjemand ne Idee, was hier falsch läuft? Wenn ich die function tier3_Backup definiere und dann ausführe, dann tut alles.