Compare commits
10
Commits
d32936f211
...
069311e898
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
069311e898 | ||
|
|
54c8d79403 | ||
|
|
a64314edbd | ||
|
|
32e2daf666 | ||
|
|
6da6e5d296 | ||
|
|
17494e3afb | ||
|
|
db2b9fbb38 | ||
|
|
35b279f356 | ||
|
|
1b94bfe6d5 | ||
|
|
80f0f7ace1 |
No files matched your search
Executable
+34
@@ -0,0 +1,34 @@
|
||||
#!/bin/sh
|
||||
|
||||
# this one makes a copy of the whole /var/www/html from boogie to BFDS
|
||||
|
||||
SCRIPTPATH=$(dirname `realpath $0`)
|
||||
cd $SCRIPTPATH
|
||||
|
||||
# rsync source -> destination
|
||||
SOURCE_PATH=/var/www/virtual/boogie/html
|
||||
DEST_PATH_FILES=/mnt/bfds/rob/backup/server/boogiedev.net/var_www
|
||||
|
||||
# path of the database backups
|
||||
DEST_PATH_DB=/mnt/bfds/rob/backup/server/boogiedev.net/db
|
||||
|
||||
# EXCLUDE="--exclude-from exclude-list"
|
||||
|
||||
# ### Get all databases
|
||||
|
||||
# kick off DB dumping
|
||||
curl --insecure --silent https://backup.boogiedev.net/dump_all_databases.php
|
||||
|
||||
# download DB dumps
|
||||
cd $DEST_PATH_DB
|
||||
curl --insecure --silent https://backup.boogiedev.net/dumps.zip > dumps.zip
|
||||
if [ -f dumps.zip ]
|
||||
then
|
||||
today=`date +%F`
|
||||
mv dumps.zip all_databases_dump_$today.zip
|
||||
else
|
||||
echo "Datenbank Dump konnte nicht herunter geladen werden"
|
||||
fi
|
||||
|
||||
## aufräumen
|
||||
curl --insecure --silent https://backup.boogiedev.net/dump_all_databases.php?cleanup_dump=1
|
||||
@@ -0,0 +1,7 @@
|
||||
backup_all_databases_cMxNrCTVLBPrNo6qaonojeejCvCepekwssh
|
||||
nextcloud/config/config.php
|
||||
nextcloud/data/root/files/Extern
|
||||
nextcloud/updater
|
||||
nextcloud/backup
|
||||
/nextcloud-data/updater-*/
|
||||
files_trashbin/
|
||||
@@ -0,0 +1 @@
|
||||
credentials.php
|
||||
@@ -0,0 +1,6 @@
|
||||
The content of this folder hast to be on the Boogie server at:
|
||||
/var/www/virtual/boogie/html/backup-boogie
|
||||
|
||||
Its the server side enpoint of the backup script running on BFDS.
|
||||
|
||||
The credentials.php has to be filled but never commited to the git
|
||||
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
|
||||
$zipfile = "dumps.zip";
|
||||
|
||||
if (isset($_GET['cleanup_dump']) && $_GET['cleanup_dump'] == 1)
|
||||
{
|
||||
Cleanup();
|
||||
die("Cleanup done");
|
||||
}
|
||||
|
||||
|
||||
$dumps_path = 'dumps/';
|
||||
if(file_exists($dumps_path))
|
||||
{
|
||||
array_map( 'unlink', array_filter((array) glob($dumps_path.'*') ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
mkdir('dumps');
|
||||
}
|
||||
|
||||
//read php file with credentials and parse it
|
||||
fopen("credentials.php", "r") or die("Unable to open file!");
|
||||
include 'credentials.php';
|
||||
//should priovide the following variables:
|
||||
// $db_host = 'host';
|
||||
// $db_user = 'user';
|
||||
// $db_pass = 'pw';
|
||||
|
||||
if ($db_host == NULL || $db_user == NULL || $db_pass == NULL) {
|
||||
die("Please provide credentials in credentials.php");
|
||||
}
|
||||
|
||||
$db_conn = new mysqli($db_host, $db_user, $db_pass);
|
||||
|
||||
$result = mysqli_query($db_conn,"SHOW DATABASES");
|
||||
while ($row = mysqli_fetch_array($result)) {
|
||||
|
||||
if($row[0] == 'information_schema' || $row[0] == 'performance_schema')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$database = $row[0];
|
||||
$dir = dirname(__FILE__) . '/'.$dumps_path.$database.'.sql';
|
||||
|
||||
exec("mysqldump --user={$db_user} --password={$db_pass} --host={$db_host} {$database} --result-file={$dir} 2>&1", $output);
|
||||
if(!empty($output))
|
||||
{
|
||||
var_dump($output);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
## Zip all dumps
|
||||
|
||||
Cleanup($zipfile);
|
||||
$zip = new ZipArchive;
|
||||
if($zip -> open($zipfile, ZipArchive::CREATE ) === TRUE)
|
||||
{
|
||||
$dir = opendir($dumps_path);
|
||||
while($file = readdir($dir)) {
|
||||
if(is_file($dumps_path.$file)) {
|
||||
$zip -> addFile($dumps_path.$file, $file);
|
||||
}
|
||||
}
|
||||
$zip ->close();
|
||||
}
|
||||
|
||||
//eine funktion die auf den url parameter cleanup_dump=1 reagiert und dann alle dumps löscht
|
||||
function Cleanup()
|
||||
{
|
||||
global $zipfile;
|
||||
|
||||
if(file_exists($zipfile))
|
||||
{
|
||||
unlink($zipfile);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
bfds soll sich regelmässig eine copy des wikis und aller scripte auf boogedev.net (uberspace) holen
|
||||
|
||||
|
||||
Um keine hindernden Passwort-Eingaben zu haben, wird ein dezediertes keyfile ohne PW verwendet.
|
||||
@@ -0,0 +1,50 @@
|
||||
@ECHO OFF
|
||||
CHCP 65001 >NUL
|
||||
REM **************************************************
|
||||
REM Dieser command sichert die Inhalt von bfds in windows
|
||||
REM auf der OFFSITE platte (Veracrypt Partition) mittels
|
||||
REM SMB Freigaben von bfds und xcopy.
|
||||
REM **************************************************
|
||||
SETLOCAL
|
||||
|
||||
SET SOURCE=\\bfds
|
||||
SET DESTINATION="B:\\"
|
||||
|
||||
echo Festplatte NASOFFSITE1 wird gesucht
|
||||
IF NOT EXIST %DESTINATION% (
|
||||
echo Festplatte NASOFFSITE1 nicht gefunden, bitte in Veracrypt einbinden!
|
||||
exit /B
|
||||
)
|
||||
|
||||
CALL :RunRobocopy "ebooks"
|
||||
CALL :RunRobocopy "movies"
|
||||
CALL :RunRobocopy "music"
|
||||
CALL :RunRobocopy "peggy"
|
||||
CALL :RunRobocopy "rob"
|
||||
exit /B %ERRORLEVEL%
|
||||
|
||||
REM **************************************************
|
||||
REM Funktion zum Ausführen von robocopy
|
||||
:RunRobocopy
|
||||
SET COPYPATH=%~1
|
||||
IF NOT EXIST %SOURCE%\%COPYPATH% (
|
||||
echo Quelle nicht gefunden! Bitte öffne die SMB Freigbe: %SOURCE%\%COPYPATH%
|
||||
exit /B %ERRORLEVEL%
|
||||
)
|
||||
SET SCRIPT_PATH=%~dp0
|
||||
SET TODAY=%DATE:~6,4%%DATE:~3,2%%DATE:~0,2%
|
||||
SET LOGFILE="%SCRIPT_PATH%robocopy_log_%COPYPATH%_%TODAY%.txt"
|
||||
echo LOGFILE: %LOGFILE%
|
||||
robocopy %SOURCE%\%COPYPATH% %DESTINATION%\%COPYPATH% /E /mt /z /J /COPY:DAT /R:3 /W:5 /LOG+:%LOGFILE% /TEE
|
||||
REM Erklärung der Parameter:
|
||||
REM /E: Kopiert Unterverzeichnisse inklusive leerer Verzeichnisse
|
||||
REM /mt: Multithreaded copying
|
||||
REM /z: Kopiert Dateien im Restart-Modus (d.h. kopiert Dateien, die bereits existieren)
|
||||
REM /COPY:DAT: Kopiert Dateiattribute, Zeitstempel und Sicherheitsinformationen
|
||||
REM /R:3: Anzahl der Wiederholungsversuche bei Fehlern
|
||||
REM /W:5: Wartezeit zwischen den Wiederholungsversuchen
|
||||
REM /J: Kopiert mit unbuffered I/O (empfohlen für große Dateien)
|
||||
REM /LOG+: Protokolliert den Kopiervorgang in eine Datei
|
||||
REM /TEE: Protokolliert den Kopiervorgang auch in der Konsole
|
||||
GOTO :EOF
|
||||
REM **************************************************
|
||||
@@ -1,2 +1,7 @@
|
||||
backup_all_databases_cMxNrCTVLBPrNo6qaonojeejCvCepekwssh
|
||||
nextcloud/config/config.php
|
||||
nextcloud/data/root/files/Extern
|
||||
nextcloud/updater
|
||||
nextcloud/backup
|
||||
/nextcloud-data/updater-*/
|
||||
files_trashbin/
|
||||
@@ -0,0 +1,3 @@
|
||||
This folder hast to be on the SBZ server
|
||||
|
||||
The credentials.php has to be filled but never commited to the git
|
||||
@@ -57,7 +57,7 @@ ssh -p $PORT -i $KEY $USER_AT_HOST "sudo umount $SBZ_MOUNT_PATH"
|
||||
|
||||
cd $DEST_PATH_DB
|
||||
# kick off DB dumping
|
||||
curl --insecure https://rob.spaceboyz.net/backup_all_databases_cMxNrCTVLBPrNo6qaonojeejCvCepekwssh/dump_all_databases.php
|
||||
curl --insecure --silent https://rob.spaceboyz.net/backup_all_databases_cMxNrCTVLBPrNo6qaonojeejCvCepekwssh/dump_all_databases.php
|
||||
# download DB dumps
|
||||
curl --insecure --silent https://rob.spaceboyz.net/backup_all_databases_cMxNrCTVLBPrNo6qaonojeejCvCepekwssh/dumps.zip > dumps.zip
|
||||
if [ -f dumps.zip ]
|
||||
|
||||
Reference in new issue
Block a user