Skip to content

Commit

Permalink
Merge pull request #5 from MrMarioMichel/development
Browse files Browse the repository at this point in the history
Spelling
  • Loading branch information
DRIgnazGortngschirl authored Jun 17, 2019
2 parents 453164a + d09823d commit f06c18d
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 37 deletions.
4 changes: 0 additions & 4 deletions ArchivStats.sh

This file was deleted.

4 changes: 4 additions & 0 deletions ArchiveStats.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
date=`date +%d%m%y`
archivesize=`du -sh ./Archive/`
echo Current size : $archivesize
3 changes: 1 addition & 2 deletions BackupConfigsCleanUp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ if [[ $REPLY =~ ^[Y]$ ]]
then
echo "I will DELETE now ALL Backuped Configs."
sleep 3
find ./Archiv -maxdepth 2 -type f -exec rm -fv {} \;
rm ./Archiv -fv
find ./Archive -maxdepth 2 -type f -exec rm -fv {} \;
fi
fi
15 changes: 8 additions & 7 deletions Checker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ fortinethostfilecount=`egrep -v "^\s*(#|$)" ./Devices/Fortinet/Fortinet-Devices.
hphostfilecount=`egrep -v "^\s*(#|$)" ./Devices/HP/HP-Devices.txt | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b" | wc -l`
ciscohostfilecount=`egrep -v "^\s*(#|$)" ./Devices/Cisco/Cisco-Devices.txt | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b" | wc -l`
dellhostfilecount=`egrep -v "^\s*(#|$)" ./Devices/DELL/DELL-Devices.txt | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b" | wc -l`
dirsinachriv=`find ./Archiv -maxdepth 1 -type d | wc -l`
configsinachive=`find ./Archiv -maxdepth 2 -type f -mtime -1 | wc -l`
minus1=1 # Caused by also counting the ./Archiv as a folder
dirsinarchive=`find ./Archive -maxdepth 1 -type d | wc -l`
configsinarchive=`find ./Archive -maxdepth 2 -type f -mmin -120 | wc -l`
minus1=1 # Caused by also counting the ./Archive as a folder

total=`expr $fortinethostfilecount + $hphostfilecount + $ciscohostfilecount + $dellhostfilecount`
dirsinachriv=`expr $dirsinachriv - $minus1`
dirsinachrive=`expr $dirsinachrive - $minus1`

echo "------------------------------------------------"
echo "Fortinet .. : $fortinethostfilecount Hosts in Host File"
Expand All @@ -18,9 +18,10 @@ echo "Cisco ..... : $ciscohostfilecount Hosts in Host File"
echo "DELL ...... : $dellhostfilecount Hosts in Host File"
echo "------------------------------------------------"
echo "Lines in Host file .......... : $total"
echo "Directorys in Archiv ........ : $dirsinachriv"
echo "Current Configs in Achive ... : $configsinachive"
echo "Directorys in Archiv ........ : $dirsinarchive"
echo "Current Configs in Archive .. : $configsinarchive"
echo "------------------------------------------------"
echo "These numbers should match!!!"
echo "(Lines in Host file) & (Current Configs in Archive) These numbers should match!!!"
echo "Otherwise you didn't got all configs listed in the host files"
echo "Start Fastdebug.sh to see more infos where those errors are"
echo "Remidner: If you got more (Directorys in Archive) than (Lines in Host file) the could be caused by a switch over from e.g. fw-01 to fw-02"
4 changes: 2 additions & 2 deletions Fortinet-Special.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ echo "Started Backup of Config's (Special)"
# <HOSTNAME>
scp -P <PORT>-v -i ./SSH-Keys/Backup-SSH-Key $user@$device:sys_config ./BackupConfigFortinet # Will copy to all devices in "Fortinet-Devices.txt" and copy it secure localy
name=`pv BackupConfigFortinet | grep -m1 'set hostname' | sed 's|["?]||g' | sed 's/\<set hostname\>//g' | sed 's/ //g' | tr -dc '[:print:]'` # Will search for the host name to set create a directory and a file named like the hostname of the network device
mkdir -v Archiv/$name
mv -v BackupConfigFortinet ./Archiv/$name/$name-$(date +"%H-%M_%d-%m-%Y").conf# Will move the copied file to the correct folder and will also rename it with the hostname
mkdir -v Archive/$name
mv -v BackupConfigFortinet ./Archive/$name/$name-$(date +"%H-%M_%d-%m-%Y").conf# Will move the copied file to the correct folder and will also rename it with the hostname
4 changes: 2 additions & 2 deletions Fortinet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ do
echo -e "Host found in hostfile --> $device"
scp -v -i ./SSH-Keys/Backup-SSH-Key $user@$device:sys_config ./BackupConfigFortinet # Will copy to all devices in "Fortinet-Devices.txt" and copy it secure localy
name=`pv BackupConfigFortinet | grep -m1 'set hostname' | sed 's|["?]||g' | sed 's/\<set hostname\>//g' | sed 's/ //g' | tr -dc '[:print:]'` # Will search for the host name to set create a directory and a file named like the hostname of the network device
mkdir -v Archiv/$name
mv -v BackupConfigFortinet ./Archiv/$name/$name-$(date +"%H-%M_%d-%m-%Y").conf # Will move the copied file to the correct folder and will also rename it with the hostname
mkdir -v Archive/$name
mv -v BackupConfigFortinet ./Archive/$name/$name-$(date +"%H-%M_%d-%m-%Y").conf # Will move the copied file to the correct folder and will also rename it with the hostname
done
3 changes: 0 additions & 3 deletions OldConfigsAchiver.sh

This file was deleted.

3 changes: 3 additions & 0 deletions OldConfigsArchiver.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
# Use gunzip -r Archive/ to unzip all ziped .gz files
date=`date +%d%m%y`
File renamed without changes.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Again just enter.

## Server side

In ```./Devices/<VENDOR>/<VENDOR>-Devices.txt``` you need to enter line by line all IP addresses. For more information have a look in any of these device .txt files.
In ./Devices/<VENDOR>/<VENDOR>-Devices.txt you need to enter line by line all IP addresses. For more information have a look in any of these device .txt files.

## Client side (Network device)

Expand Down
32 changes: 16 additions & 16 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

# Phase 1 create all directorys
echo "[i] : Setup stared"
mkdir --verbose ./Archiv
mkdir --verbose ./Archive
mkdir --verbose -p ./Devices/{Fortinet,HP,Cisco,DELL}
mkdir --verbose -p ./Modules/{Archiv,Backup,Clean,Debug}
mkdir --verbose -p ./Modules/{Archive,Backup,Clean,Debug}
mkdir --verbose ./SSH-Keys
mkdir --verbose -p ./Log/{Archv,Backup,Cisco,DELL,Fortinet,HP,Log}
mkdir --verbose -p ./Log/{Backup,Cisco,DELL,Fortinet,HP,Log}
echo "[i] : Directories where created"

# Phase 2 create all device list's
Expand Down Expand Up @@ -81,11 +81,11 @@ mv --verbose ./Fortinet-Special.sh ./Modules/Backup/Fortinet-Special.sh
mv --verbose ./DELL.sh ./Modules/Backup/DELL.sh
mv --verbose ./HP.sh ./Modules/Backup/HP.sh
mv --verbose ./Cisco.sh ./Modules/Backup/Cisco.sh
mv --verbose ./Checker.sh ./Modules/Archiv/Checker.sh
mv --verbose ./Checker.sh ./Modules/Archive/Checker.sh
mv --verbose ./Fastdebug.sh ./Modules/Debug/Fastdebug.sh
mv --verbose ./OldConfigsAchiver.sh ./Modules/Archiv/OldConfigsAchiver.sh
mv --verbose ./OldLogsAchiver.sh ./Modules/Archiv/OldLogsAchiver.sh
mv --verbose ./ArchivStats.sh ./Modules/Archiv/ArchivStats.sh
mv --verbose ./OldConfigsArchiver.sh ./Modules/Archive/OldConfigsArchiver.sh
mv --verbose ./OldLogsArchiver.sh ./Modules/Archive/OldLogsArchiver.sh
mv --verbose ./ArchiveStats.sh ./Modules/Archive/ArchiveStats.sh
mv --verbose ./BackupConfigsCleanUp.sh ./Modules/Clean/BackupConfigsCleanUp.sh
mv --verbose ./LogCleanUp.sh ./Modules/Clean/LogCleanUp.sh
echo "[i] : Modules where moved"
Expand All @@ -111,15 +111,15 @@ echo './Modules/Archiv/OldLogsArchiver.sh ./Log/Log/LogCompress/log$date.txt' >
echo './Modules/Archiv/ArchivStats.sh >> ./Log/BackupCheck/log$date.txt' >> ./Main-Launcher.sh
echo "--------------------------------------------------------------------------------"
echo "Set days after a config gets commpressed (.gz format) [2,5x-3,5x SMALLER] (Numbers only):"
read achivetimearchiv
read archivetimearchive
echo "--------------------------------------------------------------------------------"
echo "find ./Archiv -mtime +$achivetimearchiv -exec gzip {} +" >> ./Modules/Archiv/OldConfigsArchiver.sh
echo "find ./Archive -vf -mtime +$achivetimearchive -exec gzip -v {} +" >> ./Modules/Archive/OldConfigsArchiver.sh
echo "Set days after a logs gets commpressed (.gz format) [2,5x-3,5x SMALLER] (Numbers only):"
read achivetimelogs
read archivetimelogs
echo "--------------------------------------------------------------------------------"
echo "find ./Archiv -mtime +$achivetimelogs -exec gzip {} +" >> ./Modules/Archiv/OldLogsArchiver.sh
echo "find ./Archive -mtime +$archivetimelogs -exec gzip -v {} +" >> ./Modules/Archiv/OldLogsArchiver.sh

echo "du -sh ./Archiv >> ./Log/BackupCheck/log$date.txt" >> ./Modules/Archiv/ArchivStats.sh
echo "du -sh ./Archive >> ./Log/BackupCheck/log$date.txt" >> ./Modules/Archiv/ArchiveStats.sh
echo "[i] : Main Launcher where created"

# Phase 5 make the files executable
Expand All @@ -129,13 +129,13 @@ chmod --verbose 700 ./Modules/Backup/Fortinet-Special.sh
chmod --verbose 700 ./Modules/Backup/DELL.sh
chmod --verbose 700 ./Modules/Backup/HP.sh
chmod --verbose 700 ./Modules/Backup/Cisco.sh
chmod --verbose 700 ./Modules/Archiv/Checker.sh
chmod --verbose 700 ./Modules/Archive/Checker.sh
chmod --verbose 700 ./Modules/Debug/Fastdebug.sh
chmod --verbose 700 ./Modules/Clean/BackupConfigsCleanUp.sh
chmod --verbose 700 ./Modules/Clean/LogCleanUp.sh
chmod --verbose 700 ./Modules/Archiv/ArchivStats.sh
chmod --verbose 700 ./Modules/Archiv/OldConfigsAchiver.sh
chmod --verbose 700 ./Modules/Archiv/OldLogsAchiver.sh
chmod --verbose 700 ./Modules/Archive/ArchiveStats.sh
chmod --verbose 700 ./Modules/Archive/OldConfigsArchiver.sh
chmod --verbose 700 ./Modules/Archive/OldLogsArchiver.sh
echo "[i] : Modules & Lanucher where modified"

# Phase 6 create SSH Key
Expand Down

0 comments on commit f06c18d

Please sign in to comment.