Backup erstellen
- diff --git a/web/settings/navbar.html b/web/settings/navbar.html index e9c6b4279..d47da29a2 100644 --- a/web/settings/navbar.html +++ b/web/settings/navbar.html @@ -64,7 +64,7 @@ System
- Backup erstellen
+ Backup
Backup wiederherstellen
Reboot
Shutdown
diff --git a/web/settings/savebackup.php b/web/settings/savebackup.php
new file mode 100644
index 000000000..e382feb83
--- /dev/null
+++ b/web/settings/savebackup.php
@@ -0,0 +1,167 @@
+";
+ $filename = buildBackup($useExtendedFilename, $backupPath);
+ echo "";
+ echo "";
+ $globalErrorCode = ftpUpload($filename, $backupPath, $ftphostold, $ftppathold, $ftpuserold, $ftppassold);
+ } else {
+ echo "";
+ $filename = buildBackup($useExtendedFilename, $backupPath);
+ echo "";
+ }
+
+
+ function ftpUpload($filename, $backupPath, $host, $path, $user, $pass) {
+ $localfile = $backupPath.$filename;
+ $remotefile = $filename;
+ echo "Local file ".$localfile;
+ echo "Upload ".$remotefile;
+
+ $ch = curl_init();
+ $fp = fopen($localfile, 'r');
+ curl_setopt($ch, CURLOPT_URL, "ftp://".$user.":".$pass."@".$host.":".$path."/".$filename);
+ curl_setopt($ch, CURLOPT_UPLOAD, 1);
+ curl_setopt($ch, CURLOPT_INFILE, $fp);
+ curl_setopt($ch, CURLOPT_INFILESIZE, filesize($localfile));
+ curl_exec ($ch);
+ $error_no = curl_errno($ch);
+ curl_close ($ch);
+ if ($error_no > 0) {
+ $globalErrorMessage = "File uploaed failed.";
+ }
+ return $error_no;
+ }
+
+ function buildBackup($useExtendedFilename, $backupPath) {
+ // if parameter extendedFilename is passed with value 1 the filename changes
+ // from backup.tar.gz to openWB_backup_YYYY-MM-DD_HH-MM-SS.tar.gz
+
+ echo "";
+ $timestamp = date("Y-m-d") . "_" . date("H-i-s");
+ if ( $useExtendedFilename ) {
+ $filename = "openWB_backup_" . $timestamp . ".tar.gz" ;
+ } else {
+ $filename = "backup.tar.gz" ;
+ }
+
+ // first empty backup-directory
+ echo "";
+ array_map( "unlink", array_filter((array) glob($backupPath . "*") ) );
+ // then create new backup-file
+ exec("tar --exclude='/var/www/html/openWB/web/backup' --exclude='/var/www/html/openWB/.git' -czf ". $backupPath . $filename . " /var/www/html/");
+
+ return $filename;
+ }
+
+?>
+
+
+
+
+
+
+
+
+
+ Backup erstellen
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/web/settings/testftp.php b/web/settings/testftp.php
new file mode 100644
index 000000000..26d7c902d
--- /dev/null
+++ b/web/settings/testftp.php
@@ -0,0 +1,18 @@
+
\ No newline at end of file
Backup erstellen
+ + 0) { + echo '';
+ echo 'Das Backup ist fehlgeschlagen:
'; + echo $globalErrorMessage.'
'; + echo 'Curl Error Code: '.$globalErrorCode; + echo '
';
+ } else {
+ ?>
+ '; + echo $globalErrorMessage.'
'; + echo 'Curl Error Code: '.$globalErrorCode; + echo '
+ Backup-Datei erfolgreich
+
+ auf
+ erstellt.
+
+
+
+
+
+
+
+