[S] Webspace-Backup-Script
|
Verfasser |
Nachricht |
|
Beiträge: 329
Bewertung: 0
Registriert seit: Jan 2010
Status:
offline
|
[S] Webspace-Backup-Script
Hallo zusammen,
ich suche ein Backupscript für Ordner/Dateien. Also eins was ein Backup von einem bestimmten Ordner auf meinem Webspace macht. Und dann das Backup per E-Mail an mich schickt. (falls der Server down ist, hilf mir ein Link zum Backup wenig). Wenn möglich sollte es auch gleichzeitig Backups von einer MySQL-Datenbank machen können und genauso wie die FTP-Dateien per E-Mail verschicken.
Ich hoffe ihr habt etwas für mich und danke schonmal im Vorraus =)
Q6600
|
|
18.06.2011 17:52 |
|
|
Beiträge: Keine Angabe
Registriert seit: Keine Angabe
Status: Unbekannt
|
RE: [S] Webspace-Backup-Script
Wie groß soll denn bitte die EMail werden?
|
|
18.06.2011 18:07 |
|
|
Beiträge: 2.199
Bewertung: 74
Registriert seit: Oct 2007
Status:
offline
|
|
18.06.2011 18:58 |
|
|
Beiträge: 329
Bewertung: 0
Registriert seit: Jan 2010
Status:
offline
|
RE: [S] Webspace-Backup-Script
Mysqldumper kann Backups vom Webspace machen? O.o
Wie? Diese Funktion kenn ich nicht...^^
|
|
18.06.2011 19:32 |
|
|
Beiträge: 2.199
Bewertung: 74
Registriert seit: Oct 2007
Status:
offline
|
|
19.06.2011 08:51 |
|
|
Beiträge: Keine Angabe
Registriert seit: Keine Angabe
Status: Unbekannt
|
RE: [S] Webspace-Backup-Script
Zum Backup für ein Ordner/Verzeichnis brauchst du doch nur tar und mail...ist doch eigentlich ganz einfach.
|
|
19.06.2011 12:25 |
|
|
Beiträge: 329
Bewertung: 0
Registriert seit: Jan 2010
Status:
offline
|
RE: [S] Webspace-Backup-Script
Was? Ich suche ein Script dass sowas kann...
Ich weiss was man dazu braucht, danke...
|
|
19.06.2011 19:08 |
|
|
Beiträge: 468
Registriert seit: Jan 2011
Status:
offline
|
RE: [S] Webspace-Backup-Script
Hier das verlangte script.
<?php // BACKUP SYSTEM // NICHT ZUR WEITERGABE FREIGEGEBEN
// NUN EINSTELLUNGEN define("DIR", "backup/"); // Hier das Verzeichnis angeben welches gebackupt werden soll define("SAVE_DIR", "Backup/"); //Verzeichnis in welches die datum.backup.zip gespeichert werden soll // OPTIONALE EINSTELLUNGEN define("ZIP_SAVE_NAME", "{datum}-{zeit}.backup.zip"); // Name der datei die durch das Script erstellt werden soll. // Es kann verwendet werden... // {datum} = 1-1-2011 // {zeit} = 19:40:20 // {md5}{inhalt}{/md5} der inhalt Zwischen {md5} und {/md5} wird als md5 hash erstellt Dies kann z.B. das Datum und die Zeit sein define("EMAIL", true); // Stellt ein ob Email vesendet werden soll define("EMAIL_AN", "emailaddy"); //
/** * Zip file creation class. * Makes zip files. * * Based on : * * http://www.zend.com/codex.php?id=535&single=1 * By Eric Mueller <[email protected]> * * http://www.zend.com/codex.php?id=470&single=1 * by Denis125 <[email protected]> * * a patch from Peter Listiak <[email protected]> for last modified * date and time of the compressed file * * Official ZIP file format: http://www.pkware.com/appnote.txt * * @access public */ class zipfile { /** * Array to store compressed data * * @var array $datasec */ var $datasec = array();
/** * Central directory * * @var array $ctrl_dir */ var $ctrl_dir = array();
/** * End of central directory record * * @var string $eof_ctrl_dir */ var $eof_ctrl_dir = "\x50\x4b\x05\x06\x00\x00\x00\x00";
/** * Last offset position * * @var integer $old_offset */ var $old_offset = 0;
/** * Converts an Unix timestamp to a four byte DOS date and time format (date * in high two bytes, time in low two bytes allowing magnitude comparison). * * @param integer the current Unix timestamp * * @return integer the current date in a four byte DOS format * * @access private */ function unix2DosTime($unixtime = 0) { $timearray = ($unixtime == 0) ? getdate() : getdate($unixtime);
if ($timearray['year'] < 1980) { $timearray['year'] = 1980; $timearray['mon'] = 1; $timearray['mday'] = 1; $timearray['hours'] = 0; $timearray['minutes'] = 0; $timearray['seconds'] = 0; } // end if
return (($timearray['year'] - 1980) << 25) | ($timearray['mon'] << 21) | ($timearray['mday'] << 16) | ($timearray['hours'] << 11) | ($timearray['minutes'] << 5) | ($timearray['seconds'] >> 1); } // end of the 'unix2DosTime()' method
/** * Adds "file" to archive * * @param string file contents * @param string name of the file in the archive (may contains the path) * @param integer the current timestamp * * @access public */ function addFile($data, $name, $time = 0) { $name = str_replace('\\', '/', $name);
$dtime = dechex($this->unix2DosTime($time)); $hexdtime = '\x' . $dtime[6] . $dtime[7] . '\x' . $dtime[4] . $dtime[5] . '\x' . $dtime[2] . $dtime[3] . '\x' . $dtime[0] . $dtime[1]; eval('$hexdtime = "' . $hexdtime . '";');
$fr = "\x50\x4b\x03\x04"; $fr .= "\x14\x00"; // ver needed to extract $fr .= "\x00\x00"; // gen purpose bit flag $fr .= "\x08\x00"; // compression method $fr .= $hexdtime; // last mod time and date
// "local file header" segment $unc_len = strlen($data); $crc = crc32($data); $zdata = gzcompress($data); $zdata = substr(substr($zdata, 0, strlen($zdata) - 4), 2); // fix crc bug $c_len = strlen($zdata); $fr .= pack('V', $crc); // crc32 $fr .= pack('V', $c_len); // compressed filesize $fr .= pack('V', $unc_len); // uncompressed filesize $fr .= pack('v', strlen($name)); // length of filename $fr .= pack('v', 0); // extra field length $fr .= $name;
// "file data" segment $fr .= $zdata;
// "data descriptor" segment (optional but necessary if archive is not // served as file) $fr .= pack('V', $crc); // crc32 $fr .= pack('V', $c_len); // compressed filesize $fr .= pack('V', $unc_len); // uncompressed filesize
// add this entry to array $this -> datasec[] = $fr;
// now add to central directory record $cdrec = "\x50\x4b\x01\x02"; $cdrec .= "\x00\x00"; // version made by $cdrec .= "\x14\x00"; // version needed to extract $cdrec .= "\x00\x00"; // gen purpose bit flag $cdrec .= "\x08\x00"; // compression method $cdrec .= $hexdtime; // last mod time & date $cdrec .= pack('V', $crc); // crc32 $cdrec .= pack('V', $c_len); // compressed filesize $cdrec .= pack('V', $unc_len); // uncompressed filesize $cdrec .= pack('v', strlen($name) ); // length of filename $cdrec .= pack('v', 0 ); // extra field length $cdrec .= pack('v', 0 ); // file comment length $cdrec .= pack('v', 0 ); // disk number start $cdrec .= pack('v', 0 ); // internal file attributes $cdrec .= pack('V', 32 ); // external file attributes - 'archive' bit set
$cdrec .= pack('V', $this -> old_offset ); // relative offset of local header $this -> old_offset += strlen($fr);
$cdrec .= $name;
// optional extra field, file comment goes here // save to central directory $this -> ctrl_dir[] = $cdrec; } // end of the 'addFile()' method
/** * Dumps out file * * @return string the zipped file * * @access public */ function file() { $data = implode('', $this -> datasec); $ctrldir = implode('', $this -> ctrl_dir);
return $data . $ctrldir . $this -> eof_ctrl_dir . pack('v', sizeof($this -> ctrl_dir)) . // total # of entries "on this disk" pack('v', sizeof($this -> ctrl_dir)) . // total # of entries overall pack('V', strlen($ctrldir)) . // size of central dir pack('V', strlen($data)) . // offset to start of central dir "\x00\x00"; // .zip file comment length } // end of the 'file()' method
} // end of the 'zipfile' class $filename = ZIP_SAVE_NAME; $filename = str_replace("{datum}", date("d-m-Y"), $filename); $filename = str_replace("{zeit}", date("H-i-s"), $filename); $filename = preg_replace("/\{md5\}(.*)\{\/md5\}/Usi", md5("\\1"), $filename); $zip = new zipfile; backup(DIR, $zip);
function backup($DIR, $class) { $verzeichnis = opendir($DIR); // Verzeichnis lesen while ($file = readdir($verzeichnis)) { // Höhere Verzeichnisse nicht anzeigen! if ($file != "." && $file != "..") { if(is_dir($DIR.$file)) { backup($DIR.$file."/", $class); } else { $class->addFile($DIR.$file , $DIR.$file, time()); } } } // Verzeichnis schließen closedir($verzeichnis); } ob_start(); echo $zip->file(); $content = ob_get_contents(); ob_end_clean(); file_put_contents(SAVE_DIR.$filename, $content); if(EMAIL == true) { $empfaenger = "[email protected]"; // Empfänger E-Mail Adresse $betreff = "Backup wurde erstellt!"; // Betreff $dateiname = $filename; // Dateiname $dateiname_mail = $filename; $id = md5(uniqid(time())); $dateiinhalt = $content; $kopf = "From: [email protected]\n"; $kopf .= "MIME-Version: 1.0\n"; $kopf .= "Content-Type: multipart/mixed; boundary=$id\n\n"; $kopf .= "\n--$id"; // Content-Type: image/gif, image/jpeg, image/png » MIME-Typen - selfHtml.org $kopf .= "\nContent-Type: application/zip; name=$dateiname_mail\n"; $kopf .= "Content-Transfer-Encoding: base64\n"; $kopf .= "Content-Disposition: attachment; filename=$dateiname_mail\n\n"; $kopf .= chunk_split(base64_encode($dateiinhalt)); $kopf .= "\n--$id--"; mail($empfaenger, $betreff, "Dies ist eine Automatische Email die die backup.php erstellt hat.", $kopf); // E-Mail versenden ?> Das Backup <?php echo $filename; ?> wurde gespeichert und per Email verschickt. <?php } else { ?> Das Backup <?php echo $filename; ?> wurde gespeichert. <?php } ?>
[Link: Registrierung erforderlich]
Du brauchst einen Ts3 für einen PCW, dann schau vorbei [Link: Registrierung erforderlich]
|
|
19.06.2011 19:19 |
|
|
Beiträge: Keine Angabe
Registriert seit: Keine Angabe
Status: Unbekannt
|
RE: [S] Webspace-Backup-Script
Was? Ich suche ein Script dass sowas kann...
Ich weiss was man dazu braucht, danke...
Wenn du das doch weißt, wieso bemühst du dich dann nicht selber?
|
|
19.06.2011 19:59 |
|
|
Beiträge: 62
Bewertung: 3
Registriert seit: Jun 2011
Status:
offline
|
RE: [S] Webspace-Backup-Script
Wen Plesk auf dem Server vorhanden ist, kann auch ein kompletes Backup (FTP, Datenbanken, Domains) usw. gemacht werden!
http://myb-web.at/sign.png(!https)
|
|
22.06.2011 18:31 |
|
|