Hier ein Kleines Script um das Backup durch Images bei Netcup-Vservern zu automatisieren. (Rotierendes Backup).
Das ganze per Cron einbinden. Achtung es werden zum Beispiel bei wöchentlicher Ausführung des Crons alle Backups überschrieben in Wochen zurückgezählt.
#!/bin/sh # # Als Anreiz diente ein Script von # Michael Geiger - tux1337 - www.geigers-site.de # # Copyright (C) 2011 Christoph Schuster | ndurchx | www.n-durch-x.de #Copyright (C) 2011 Phil # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation; either version 3 of the License, or (at your # option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, see <http://www.gnu.org/licenses/>. #</sup> #check for running process while [ -e /tmp/nvcp/vcp.pid ]; do if ( kill -0 `cat /tmp/nvcp/vcp.pid` 2> /dev/null ); then sleep 5 else rm -R /tmp/nvcp fi done #CONFIG user="" #your vcp login name password="" #your vcp password servername="" #your vserver name (vXXXXXXXXXXXX) maxbackups=2 # Maximale Backup des Hostingpaketes #CONFIG END #PARAMETERS # normally you dont have to change that #PARAMETERS END mkdir /tmp/nvcp chmod 600 /tmp/nvcp cd /tmp/nvcp echo $$ > vcp.pid #Login curl -b cookie.txt -c cookie.txt -d "doLogin=Login&username=$user&password=$password" --url https://www.vservercontrolpanel.de/Login curl -b cookie.txt -o tmp.txt --url https://www.vservercontrolpanel.de/Home tr -d \\012 < tmp.txt > servers.txt serverid=`grep -o "selectedVServerId=[0-9]\{1,10\}[^0-9]*$servername" servers.txt | grep -m 1 -o "Id=[0-9]*" | grep -o [0-9]*` curl -b cookie.txt -o backups.txt --url "https://www.vservercontrolpanel.de/VServers?selectedVServerId=$serverid&page=backup" grep -o -R $servername"_[0-9]\{4\}.[0-9]\{2\}.[0-9]\{2\}_[0-9]\{2\}:[0-9]\{2\}" backups.txt |uniq > backupsavailable.txt lines=`wc -l backupsavailable.txt | cut -f1 -d' '` echo $lines if [ $lines -eq $maxbackups ] then btime=`grep -o -R $servername"_[0-9]\{4\}.[0-9]\{2\}.[0-9]\{2\}_[0-9]\{2\}:[0-9]\{2\}" backupsavailable.txt |uniq |sort |head -n1` curl -b cookie.txt -d "renewBackup=yes&backupToRenew=$btime&comment=Weekly&renewBackup=Backup%20erneuern" --url "https://www.vservercontrolpanel.de/VServers?selectedVServerId=$serverid&page=backup" echo "Backup erneuern" echo $btime else curl -b cookie.txt -d "createNewBackup=yes&newBackup=neues%20Backup%20anlegen&comment=Weekly" --url "https://www.vservercontrolpanel.de/VServers?selectedVServerId=$serverid&page=backup" echo "NEUES BACKUP ANLEGEN" fi #Logout curl -b cookie.txt --url https://www.vservercontrolpanel.de/Logout rm -R /tmp/nvcp exit 0