Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
systems:linux_maintenance_scripts [2018/05/01 14:48] smayr [Backup Critical Data and Configuration] |
systems:linux_maintenance_scripts [2018/05/01 15:07] (current) smayr [RSync] |
||
---|---|---|---|
Line 1: | Line 1: | ||
== Linux Maintenance Scripts == | == Linux Maintenance Scripts == | ||
+ | == Services == | ||
+ | ==== BIND/DNS ==== | ||
+ | '' | ||
+ | <code bash> | ||
+ | #!/bin/bash | ||
+ | ## script: ./ | ||
+ | |||
+ | #/ | ||
+ | #/ | ||
+ | / | ||
+ | </ | ||
+ | |||
+ | ==== DHCP ==== | ||
+ | '' | ||
+ | <code bash> | ||
+ | #!/bin/bash | ||
+ | ## script: ./ | ||
+ | |||
+ | #service isc-dhcp-server stop | ||
+ | #service isc-dhcp-server start | ||
+ | service isc-dhcp-server restart | ||
+ | |||
+ | # Check status | ||
+ | ps aux | grep dhcpd | ||
+ | </ | ||
+ | |||
+ | ==== Windows Server Mapping ==== | ||
+ | '' | ||
+ | <code bash> | ||
+ | #!/bin/bash | ||
+ | ## script: ./ | ||
+ | ## Mount and map Windows backup server (for backup purposes) | ||
+ | mount -t cifs -o username=backuponly, | ||
+ | </ | ||
+ | |||
+ | ==== RSync ==== | ||
+ | '' | ||
+ | <code bash> | ||
+ | #!/bin/bash | ||
+ | |||
+ | #rsync --verbose | ||
+ | # --recursive --times --perms --links --delete \ | ||
+ | # --exclude " | ||
+ | # 192.168.0.31: | ||
+ | |||
+ | # Website | ||
+ | rsync --archive --verbose --progress --stats --rsh=/ | ||
+ | --links --delete --exclude=stats 192.168.0.31:: | ||
+ | |||
+ | # Databases | ||
+ | rsync --archive --verbose --progress --stats --rsh=/ | ||
+ | --links --delete 192.168.0.31:: | ||
+ | |||
+ | # Root user home | ||
+ | rsync --archive --verbose --progress --stats --rsh=/ | ||
+ | --links --delete 192.168.0.31:: | ||
+ | |||
+ | # Subserver Repositories | ||
+ | rsync --archive --verbose --progress --stats --rsh=/ | ||
+ | --links --delete 192.168.0.31:: | ||
+ | </ | ||
+ | |||
+ | == Anti-spam / Anti-crack == | ||
+ | Run this script to scan the website and see signs of spamming or cracking: '' | ||
+ | <code bash> | ||
+ | #!/bin/bash | ||
+ | ## script: scan-website.sh | ||
+ | ## | ||
+ | |||
+ | echo "Scan Website for vulnerabilities" | ||
+ | |||
+ | cd /var/www | ||
+ | find . -name " | ||
+ | find . -name " | ||
+ | find . -name " | ||
+ | find . -name " | ||
+ | find . -name " | ||
+ | find . -name " | ||
+ | less / | ||
+ | </ | ||
== Mail Spool Maintenance == | == Mail Spool Maintenance == | ||
Line 242: | Line 322: | ||
gzip backup/ | gzip backup/ | ||
done | done | ||
+ | </ | ||
+ | |||
+ | ==== Backup to Window Server ==== | ||
+ | If you need to backup data to a remote Windows server (running Samba), use this script ''' | ||
+ | <code bash> | ||
+ | #!/bin/bash | ||
+ | ## script: / | ||
+ | ## | ||
+ | |||
+ | ###!!!! THIS SCRIPT IS DISABLED | ||
+ | ###!!!! COMMENT OUT THIS NEXT LINE TO ENABLE | ||
+ | #exit 99 | ||
+ | |||
+ | # | ||
+ | # Define Target Directory | ||
+ | # | ||
+ | SOURCEDIR="/ | ||
+ | TARGETDIR="/ | ||
+ | |||
+ | # Verify if source is available, otherwise we bail out | ||
+ | if [ ! -d " | ||
+ | echo " Nothing to backup on $(date). Source directory $SOURCEDIR does not exist." | ||
+ | echo " Nothing to backup on $(date)." | ||
+ | echo " Source directory $SOURCEDIR does not exist." | ||
+ | echo " Exiting." | ||
+ | exit; | ||
+ | fi | ||
+ | |||
+ | # Try to create and mount TargetDir if it does not exist | ||
+ | if [ ! -d " | ||
+ | mkdir $TARGETDIR | ||
+ | fi | ||
+ | |||
+ | # Perform operations if TargetDir exists | ||
+ | if [ -d " | ||
+ | # | ||
+ | # Mount Windows server samba drive (CIFS) | ||
+ | # | ||
+ | # Requires cifs-utils to be installed for mount to work. | ||
+ | mount -t cifs -o username=backuponly, | ||
+ | |||
+ | # | ||
+ | # Remove old backup files | ||
+ | # | ||
+ | rm -rf $TARGETDIR/ | ||
+ | |||
+ | # | ||
+ | # Backup | ||
+ | # | ||
+ | # Backup ALL files | ||
+ | #cp -R $SOURCEDIR $TARGETDIR | ||
+ | |||
+ | # Backup all files EXCEPT ' | ||
+ | # Method 1: cp *? | ||
+ | # Method 2: cp `ls $SOURCEDIR |grep -v < | ||
+ | cd $SOURCEDIR | ||
+ | cp `ls $SOURCEDIR | grep -v downloads` $TARGETDIR/ | ||
+ | |||
+ | # | ||
+ | # Send Reminder | ||
+ | # | ||
+ | ## send reminder to sysadmin to pull the tarball from the server. | ||
+ | echo " | ||
+ | echo " | ||
+ | echo " | ||
+ | echo " | ||
+ | #mail root@localhost -s "Get the backup tarball off the server" | ||
+ | |||
+ | else | ||
+ | |||
+ | ## send message to sysadmin. | ||
+ | echo " | ||
+ | echo " | ||
+ | #mail root@localhost -s " | ||
+ | |||
+ | fi | ||
+ | |||
</ | </ |