Added elkarbackup CT
This commit is contained in:
1
CT-Files/elkarbackupALP/Configs/crontab
Normal file
1
CT-Files/elkarbackupALP/Configs/crontab
Normal file
@@ -0,0 +1 @@
|
||||
* * * * * APP_ENV=prod APP_DEBUG=0 php /opt/elkarbackup/srv/bin/console elkarbackup:tick
|
||||
27
CT-Files/elkarbackupALP/Configs/elkarbackupconf.yaml
Normal file
27
CT-Files/elkarbackupALP/Configs/elkarbackupconf.yaml
Normal file
@@ -0,0 +1,27 @@
|
||||
parameters:
|
||||
database_driver: pdo_mysql
|
||||
database_host: DBServer
|
||||
database_port: null
|
||||
database_name: DBName
|
||||
database_user: DBUser
|
||||
database_password: DBPass
|
||||
mailer_transport: smtp
|
||||
mailer_host: localhost
|
||||
mailer_user: null
|
||||
mailer_password: null
|
||||
locale: en
|
||||
secret: ElkarToken
|
||||
database_path: null
|
||||
upload_dir: /opt/elkarbackup/uploads
|
||||
public_key: /opt/elkarbackup/home/.ssh/id_rsa.pub
|
||||
max_log_age: P1Y
|
||||
tmp_dir: /tmp
|
||||
rsnapshot: /usr/bin/rsnapshot
|
||||
warning_load_level: 0.8
|
||||
pagination_lines_per_page: 20
|
||||
url_prefix: null
|
||||
disable_background: true
|
||||
mailer_from: null
|
||||
home: /opt/elkarbackup/home
|
||||
max_parallel_jobs: 1
|
||||
post_on_pre_fail: true
|
||||
56
CT-Files/elkarbackupALP/Configs/nginx.conf
Normal file
56
CT-Files/elkarbackupALP/Configs/nginx.conf
Normal file
@@ -0,0 +1,56 @@
|
||||
user nginx;
|
||||
worker_processes auto;
|
||||
error_log /var/log/nginx/error.log notice;
|
||||
pid /var/run/nginx.pid;
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
http {
|
||||
sendfile on;
|
||||
tcp_nopush on;
|
||||
tcp_nodelay on;
|
||||
keepalive_timeout 65;
|
||||
types_hash_max_size 2048;
|
||||
server_tokens off;
|
||||
client_body_buffer_size 10K;
|
||||
client_header_buffer_size 1k;
|
||||
client_max_body_size 8m;
|
||||
large_client_header_buffers 4 4k;
|
||||
server_names_hash_bucket_size 64;
|
||||
root /usr/share/nginx/html;
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
access_log off;
|
||||
error_log /var/log/nginx/error.log;
|
||||
#Server config for RainLoop
|
||||
server {
|
||||
listen 80 default_server;
|
||||
listen [::]:80 default_server;
|
||||
root /opt/elkarbackup/srv/public;
|
||||
index index.html index.php;
|
||||
server_name _;
|
||||
|
||||
location / {
|
||||
try_files $uri /index.php$is_args$args;
|
||||
}
|
||||
|
||||
location ~ ^/index\.php(/|$) {
|
||||
fastcgi_pass unix:/run/php-fpm7/php-fpm.sock;
|
||||
fastcgi_split_path_info ^(.+\.php)(/.*)$;
|
||||
include fastcgi_params;
|
||||
fastcgi_param APP_ENV prod;
|
||||
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
|
||||
fastcgi_param DOCUMENT_ROOT $realpath_root;
|
||||
internal;
|
||||
}
|
||||
|
||||
location ~ \.php$ {
|
||||
return 404;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
15
CT-Files/elkarbackupALP/Configs/php.conf
Normal file
15
CT-Files/elkarbackupALP/Configs/php.conf
Normal file
@@ -0,0 +1,15 @@
|
||||
[elkarbackup]
|
||||
user = nginx
|
||||
group = nginx
|
||||
listen = /run/php-fpm7/php-fpm.sock
|
||||
listen.owner = nginx
|
||||
listen.group = nginx
|
||||
php_admin_value[error_log] = /var/log/php-fpm.error.log
|
||||
php_admin_value [date.timezone] = Europe/Amsterdam
|
||||
|
||||
pm = dynamic
|
||||
pm.max_children = 5
|
||||
pm.start_servers = 2
|
||||
pm.min_spare_servers = 1
|
||||
pm.max_spare_servers = 3
|
||||
chdir = /
|
||||
2
CT-Files/elkarbackupALP/Configs/phpTimezone.ini
Normal file
2
CT-Files/elkarbackupALP/Configs/phpTimezone.ini
Normal file
@@ -0,0 +1,2 @@
|
||||
[Date]
|
||||
date.timezone = Europe/Amsterdam
|
||||
3
CT-Files/elkarbackupALP/Configs/sudofile
Normal file
3
CT-Files/elkarbackupALP/Configs/sudofile
Normal file
@@ -0,0 +1,3 @@
|
||||
Cmnd_Alias ELKARBACKUP_SCRIPTS=/opt/elkarbackup/uploads/*
|
||||
Defaults!ELKARBACKUP_SCRIPTS env_keep += "ELKARBACKUP_LEVEL ELKARBACKUP_EVENT ELKARBACKUP_URL ELKARBACKUP_ID ELKARBACKUP_PATH ELKARBACKUP_STATUS ELKARBACKUP_CLIENT_NAME ELKARBACKUP_JOB_NAME ELKARBACKUP_OWNER_EMAIL ELKARBACKUP_RECIPIENT_LIST ELKARBACKUP_CLIENT_TOTAL_SIZE ELKARBACKUP_JOB_TOTAL_SIZE ELKARBACKUP_JOB_RUN_SIZE ELKARBACKUP_CLIENT_STARTTIME ELKARBACKUP_CLIENT_ENDTIME ELKARBACKUP_JOB_STARTTIME ELKARBACKUP_JOB_ENDTIME ELKARBACKUP_SSH_ARGS"
|
||||
nginx ALL = NOPASSWD: ELKARBACKUP_SCRIPTS
|
||||
@@ -0,0 +1,3 @@
|
||||
#!/bin/ash
|
||||
#Shoud be uploaded in Elkarbackup under scrips and set ran as Job Pre and Post
|
||||
ssh -oStrictHostKeyChecking=no $(echo $ELKARBACKUP_URL | sed 's|:.*||') bash /opt/Elkar-MysqlBackup.sh "$ELKARBACKUP_EVENT"
|
||||
@@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
##Should be as "/opt/Elkar-MysqlBackup.sh" on the MySQL server
|
||||
## MysqlUser needs following Global privilleges: SELECT, PROCESS, SHOW DATABASES, LOCK TABLES, TRIGGER, SHOW VIEW
|
||||
USER="<MysqlUserName>"
|
||||
PASSWORD="<MysqlUserPassword>"
|
||||
OUTPUT="/tmp/mysqlBCK"
|
||||
|
||||
PRE () {
|
||||
mkdir $OUTPUT
|
||||
ExcludeDatabases="Database|information_schema|performance_schema|mysql|sys"
|
||||
databases=$(mysql -u $USER -p$PASSWORD -e "SHOW DATABASES;" | tr -d "| " | egrep -v $ExcludeDatabases)
|
||||
|
||||
for db in $databases; do
|
||||
if [[ "$db" != "information_schema" ]] && [[ "$db" != "performance_schema" ]] && [[ "$db" != "mysql" ]] && [[ "$db" != _* ]] ; then
|
||||
echo "Dumping database: $db"
|
||||
mysqldump -u $USER -p$PASSWORD --databases $db > $OUTPUT/$db.sql
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
POST () {
|
||||
rm -rf /tmp/mysqlBCK
|
||||
}
|
||||
|
||||
$1
|
||||
25
CT-Files/elkarbackupALP/Extras/MySQLBackup/ReadMe.md
Normal file
25
CT-Files/elkarbackupALP/Extras/MySQLBackup/ReadMe.md
Normal file
@@ -0,0 +1,25 @@
|
||||
# MySQL backup tool for Elkarbackup
|
||||
|
||||
## Explanation
|
||||
* Elkarbackup server runs `MySQLBackup-RemoteTrigger.sh` before starting the backup to login to the target (MySQL) server to run `MySQLBackup-Tool.sh` with the PRE argument.
|
||||
This will ask remote mysql to dump all databases to a SQL file to the local temporary backup location (default: /tmp/mysqlBCK)
|
||||
* Elkarbackup will store the temporary backup location
|
||||
* Elkarbackup server runs `MySQLBackup-RemoteTrigger.sh` after running the backup to login to the target (MySQL) server to run `MySQLBackup-Tool.sh` with the POST argument.
|
||||
This will ask the remote to clean the temporary backup location
|
||||
|
||||
## Setup
|
||||
|
||||
### Steps on MySQL Server
|
||||
* Make sure SSH server is running
|
||||
1. Add the SSH public key from root@elkarbackupServer and elkarbackupAPP(Downloaded from cogwheel/settings icon > Manage parameters)
|
||||
2. Create a Mysql user with the following Global privilleges: `SELECT, PROCESS, SHOW DATABASES, LOCK TABLES, TRIGGER, SHOW VIEW`
|
||||
be carefull with special charactes in the password
|
||||
3. Save `MySQLBackup-Tool.sh` to `/opt/Elkar-MysqlBackup.sh`
|
||||
4. Update the variables in `/opt/Elkar-MysqlBackup.sh` to the newly created user
|
||||
|
||||
## Steps Elkarbackup WebUI
|
||||
1. Under `script` tab add the `MySQLBackup-RemoteTrigger.sh` with `Run as` option Before and After Job
|
||||
2. Under `Jobs` tab add the MySQL server as Client
|
||||
3. Under `Jobs` tab> + on the mysql client to add job
|
||||
4. Set Path to the temporary backup location (default: /tmp/mysqlBCK)
|
||||
Pre and Post sctipt to the just created `script`
|
||||
20
CT-Files/elkarbackupALP/Scripts/FirstRun.sh
Normal file
20
CT-Files/elkarbackupALP/Scripts/FirstRun.sh
Normal file
@@ -0,0 +1,20 @@
|
||||
#!/bin/ash
|
||||
ThisScriptConfigured=no
|
||||
##DB
|
||||
MysqlIP=127.0.0.1
|
||||
MysqlUsername=User
|
||||
MysqlDatabase=DB
|
||||
MysqlPassword=MysqlPassword
|
||||
|
||||
#Check if script is configured
|
||||
if [ $ThisScriptConfigured = no ]; then
|
||||
echo "Script is not configured"
|
||||
exit
|
||||
fi
|
||||
|
||||
sed -i -e 's/DBServer/'$MysqlIP'/' -e 's/DBName/'$MysqlDatabase'/' -e 's/DBUser/'$MysqlUsername'/' -e 's/DBPass/'$MysqlPassword'/' -e 's/ElkarToken/'$(tr -dc 'A-Za-z0-9!#%()*+,-.:;<=>?@[]^_{|}~' 2>/dev/null </dev/urandom | head -c 20 ; echo )'/' /opt/elkarbackup/srv/config/parameters.yaml
|
||||
ElkarConsole="sudo -u nginx APP_ENV=prod APP_DEBUG=0 php /opt/elkarbackup/srv/bin/console"
|
||||
$ElkarConsole cache:clear
|
||||
$ElkarConsole doctrine:schema:create
|
||||
$ElkarConsole elkarbackup:generate_keypair
|
||||
APP_ENV=prod APP_DEBUG=0 php /opt/elkarbackup/srv/bin/console elkarbackup:create_admin
|
||||
44
CT-Files/elkarbackupALP/Scripts/Init.sh
Normal file
44
CT-Files/elkarbackupALP/Scripts/Init.sh
Normal file
@@ -0,0 +1,44 @@
|
||||
#!/bin/ash
|
||||
|
||||
#Install Composer
|
||||
EXPECTED_CHECKSUM="$(curl -L https://composer.github.io/installer.sig)"
|
||||
curl -L -o /tmp/composer-setup.php https://getcomposer.org/installer
|
||||
ACTUAL_CHECKSUM="$(sha384sum /tmp/composer-setup.php| awk '{ print $1 }')"
|
||||
|
||||
if [ "$EXPECTED_CHECKSUM" != "$ACTUAL_CHECKSUM" ]
|
||||
then
|
||||
>&2 echo 'ERROR: Invalid installer checksum'
|
||||
rm composer-setup.php
|
||||
fi
|
||||
|
||||
mkdir -p /opt/composer
|
||||
php /tmp/composer-setup.php --quiet --install-dir=/opt/composer
|
||||
rm /tmp/composer-setup.php
|
||||
|
||||
#Install elkarbackup
|
||||
mkdir -p /opt/elkarbackup/srv /opt/elkarbackup/home /opt/elkarbackup/uploads
|
||||
tar -C /opt/elkarbackup/srv -xzf /opt/Setup/elkb.tar.gz --strip 1
|
||||
rm -f /opt/Setup/elkb.tar.gz
|
||||
chown -R nginx:nginx /opt/elkarbackup
|
||||
sudo -u nginx php /opt/composer/composer.phar install -n --working-dir=/opt/elkarbackup/srv --no-dev
|
||||
mv /opt/Setup/Configs/elkarbackupconf.yaml /opt/elkarbackup/srv/config/parameters.yaml
|
||||
sed -i 's#/var/cache/nginx#/opt/elkarbackup/home#g' /etc/passwd
|
||||
|
||||
#Configure Nginx
|
||||
rm -rf /etc/nginx/conf.d
|
||||
mv /opt/Setup/Configs/nginx.conf /etc/nginx/nginx.conf
|
||||
|
||||
#Configure Php
|
||||
rm -rf /etc/php8/php-fpm.d/*
|
||||
mv /opt/Setup/Configs/php.conf /etc/php7/php-fpm.d/elkarbackup.conf
|
||||
mv /opt/Setup/Configs/phpTimezone.ini /etc/php7/conf.d/04_date_timezone.ini
|
||||
|
||||
#Configure Crontab
|
||||
mv /opt/Setup/Configs/crontab /etc/crontabs/nginx
|
||||
|
||||
#Configure Sudo
|
||||
mv /opt/Setup/Configs/sudofile /etc/sudoers.d/elkarbackup
|
||||
|
||||
#Enable services on boot
|
||||
rc-update add nginx
|
||||
rc-update add php-fpm7
|
||||
Reference in New Issue
Block a user