DrivePolling

Aus Programmers Guide

(Unterschied zwischen Versionen)
Wechseln zu: Navigation, Suche
(Die Seite wurde neu angelegt: „= Script to Check if Disk Status Changes = Run this Script in the Local Crontab:<br> <source lang="bash"> crontab -e #*/5 * * * * root bash /etc/backup-p…“)
Zeile 10: Zeile 10:
If the lockfile is available, you can [[ScriptBackup|Backup Data]] or use the disk for other work.  
If the lockfile is available, you can [[ScriptBackup|Backup Data]] or use the disk for other work.  
-
<br>  
+
<br> <source lang="bash">
-
<source lang="bash">
+
#!/bin/bash
#!/bin/bash
device="/dev/disk/by-id/"
device="/dev/disk/by-id/"
-
 
lock="/var/lock/"
lock="/var/lock/"
platte1="usb-BUFFALO_HD-PXU2_001010070301C5160-0:0-part1"
platte1="usb-BUFFALO_HD-PXU2_001010070301C5160-0:0-part1"
-
platte2="usb-BUFFALO_HD-PXU2_0010100703010DD10-0:0-part1"
 
mailadresse="script@firma.de"
mailadresse="script@firma.de"
 +
cd $device
cd $device
Zeile 46: Zeile 44:
echo "pl 1 nix zu tun"
echo "pl 1 nix zu tun"
fi
fi
-
 
-
cd $device
 
-
fi
 
-
 
-
if ls -l| grep "$platte2">/dev/null
 
-
then
 
-
echo "Platte 2 verbunden"
 
-
cd $lock
 
-
        if ls -l|grep "$platte2">/dev/null
 
-
                then
 
-
                echo "pl 2 nothing to do"
 
-
                else
 
-
                echo "pl 2 file anlegen"
 
-
echo "Zweite Backup-Platte wurde erfolgreich verbunden und die Nacht zum Backup herangezogen." | mail -s "Festplatte 2 verbunden" $mailadresse
 
-
                touch "$platte2"
 
-
        fi
 
-
cd $device
 
-
else
 
-
echo "Platte 2 getrennt"
 
-
cd $lock
 
-
        if ls -l|grep "$platte2">/dev/null
 
-
                then
 
-
                echo "pl 2 auswerfen"
 
-
                rm "$platte2"
 
-
                echo "Zweite Backup-Platte wurde getrennt." | mail -s "Festplatte 2 getrennt" $mailadresse
 
-
                else
 
-
                echo "pl 2 nix zu tun"
 
-
        fi
 
cd $device
cd $device
Zeile 79: Zeile 49:
exit 0
exit 0
-
 
-
 
</source>
</source>

Version vom 06:55, 2. Nov. 2010

Script to Check if Disk Status Changes

Run this Script in the Local Crontab:
crontab -e
#*/5 *   * * *   root    bash /etc/backup-platten-polling > /dev/null 2>&1

If the online Status changes, the script create or delete the lock file in /var/lock/

If the lockfile is available, you can Backup Data or use the disk for other work.


#!/bin/bash
 
device="/dev/disk/by-id/"
lock="/var/lock/"
platte1="usb-BUFFALO_HD-PXU2_001010070301C5160-0:0-part1"
mailadresse="script@firma.de"
 
cd $device
 
if ls -l| grep "$platte1">/dev/null
	then
	echo "Platte 1 verbunden"
	cd $lock
	if ls -l|grep "$platte1">/dev/null
		then
		echo "pl 1 nothing to do"
		else
		echo "pl 1 file anlegen"
		echo "Erste Backup-Platte wurde erfolgreich verbunden und die Nacht zum Backup herangezogen." | mail -s "Festplatte 1 verbunden" $mailadresse
		touch "$platte1"
	fi
cd $device
else
	echo "Platte 1 getrennt"
	cd $lock
	if ls -l|grep "$platte1">/dev/null
		then
		echo "pl 1 auswerfen"
                rm "$platte1"
                echo "Erste Backup-Platte wurde getrennt." | mail -s "Festplatte 1 getrennt" $mailadresse
		else
		echo "pl 1 nix zu tun"
	fi
 
cd $device
fi
 
exit 0
Persönliche Werkzeuge