add first draft boogie backup scripts
This commit is contained in:
1 parent
db2b9fbb38
commit
17494e3afb
6 files changed
+117
No files matched your search
@@ -0,0 +1,37 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# this one makes a copy of the whole /var/www/html from boogiedev
|
||||||
|
|
||||||
|
todo!
|
||||||
|
|
||||||
|
SCRIPTPATH=$(dirname `realpath $0`)
|
||||||
|
cd $SCRIPTPATH
|
||||||
|
|
||||||
|
# rsync source -> destination
|
||||||
|
SOURCE_PATH=/var/www/virtual/boogie/html
|
||||||
|
DEST_PATH_FILES=/mnt/bfds/rob/backup/server/boggiedev.net/var_www
|
||||||
|
|
||||||
|
# # ssh credentials
|
||||||
|
PORT="22"
|
||||||
|
KEY="${SCRIPTPATH}/boogie_keyless"
|
||||||
|
USER_AT_HOST="boogie@spaceboyz.net"
|
||||||
|
|
||||||
|
# path of the database backups
|
||||||
|
DEST_PATH_DB=/mnt/bfds/rob/backup/server/spaceboyz.net/mariadb
|
||||||
|
|
||||||
|
# EXCLUDE="--exclude-from exclude-list"
|
||||||
|
|
||||||
|
# ### Get all databases
|
||||||
|
|
||||||
|
# cd $DEST_PATH_DB
|
||||||
|
# # kick off DB dumping
|
||||||
|
# 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 ]
|
||||||
|
# then
|
||||||
|
# today=`date +%F`
|
||||||
|
# mv dumps.zip all_databases_dump_$today.zip
|
||||||
|
# else
|
||||||
|
# echo "Datenbank Dump konnte nicht herunter geladen werden"
|
||||||
|
# fi
|
||||||
@@ -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,3 @@
|
|||||||
|
This folder hast to be on the Boogie server
|
||||||
|
|
||||||
|
The credentials.php has to be filled but never commited to the git
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
<?php
|
||||||
|
ini_set('display_errors', 1);
|
||||||
|
ini_set('display_startup_errors', 1);
|
||||||
|
error_reporting(E_ALL);
|
||||||
|
|
||||||
|
$dumps_path = 'dumps/';
|
||||||
|
if(file_exists($dumps_path))
|
||||||
|
{
|
||||||
|
array_map( 'unlink', array_filter((array) glob($dumps_path.'*') ) );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mkdir('dumps');
|
||||||
|
}
|
||||||
|
|
||||||
|
read credential file
|
||||||
|
$credential_file = fopen("credentials.php", "r") or die("Unable to open file!");
|
||||||
|
//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, $user, $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={$user} --password={$pass} --host={$host} {$database} --result-file={$dir} 2>&1", $output);
|
||||||
|
if(!empty($output))
|
||||||
|
{
|
||||||
|
var_dump($output);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
## Zip all dumps
|
||||||
|
$zipfile = "dumps.zip";
|
||||||
|
|
||||||
|
if(file_exists($zipfile))
|
||||||
|
{
|
||||||
|
unlink($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();
|
||||||
|
}
|
||||||
@@ -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.
|
||||||
Reference in new issue
Block a user