Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
Restyaboard
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Merge Requests
0
Merge Requests
0
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Ali Arshad
Restyaboard
Commits
edc8e3df
Commit
edc8e3df
authored
Jun 03, 2018
by
Ali Arshad
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
initial setup
parent
623679fe
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
208 additions
and
14 deletions
+208
-14
Dockerfile
BACKUP/Dockerfile
+27
-0
backup.sh
BACKUP/backup.sh
+147
-0
Dockerfile
Restyaboard/Dockerfile
+1
-1
docker-entrypoint.sh
Restyaboard/docker-entrypoint.sh
+0
-0
supervisord.conf
Restyaboard/supervisord.conf
+0
-0
docker-compose.yml
docker-compose.yml
+33
-13
myPic.png
media/User/1/myPic.png
+0
-0
No files found.
BACKUP/Dockerfile
0 → 100644
View file @
edc8e3df
FROM
alpine
###################################################### Update APK #######################################################
RUN
apk update
###################################################### Install zip mailx & cron #######################################################
RUN
apk add
--update
\
mysql-client
\
zip
\
bash
\
curl
\
openssl
\
heirloom-mailx
\
postgresql
\
postgresql-client
#################################################### Setting up backups ####################################################
ADD
backup.sh /backup.sh
RUN
chmod u+x /backup.sh
RUN
touch /var/log/cron.log
RUN
echo
"0 8 * * 1 bash /backup.sh >> /var/log/cron.log 2>&1
\n\
"
>>
/crontab.txt
RUN
/usr/bin/crontab /crontab.txt
#################################################### Setting up cron ####################################################
CMD
/usr/sbin/crond && tail -f /var/log/cron.log
BACKUP/backup.sh
0 → 100644
View file @
edc8e3df
#!/bin/bash
function
encodeURL
()
{
local
-r
url
=
"
${
1
}
"
local
i
=
0
local
walker
=
''
for
((
i
=
0
;
i <
${#
url
}
;
i++
))
do
walker
=
"
${
url
:i:1
}
"
case
"
${
walker
}
"
in
[
a-zA-Z0-9.~_-]
)
printf
"
${
walker
}
"
;;
' '
)
printf
+
;;
*
)
printf
'%%%X'
"'
${
walker
}
"
;;
esac
done
}
function
trimString
()
{
local
-r
string
=
"
${
1
}
"
sed
's,^[[:blank:]]*,,'
<<<
"
${
string
}
"
| sed
's,[[:blank:]]*$,,'
}
function
isEmptyString
()
{
local
-r
string
=
"
${
1
}
"
if
[[
"
$(
trimString
"
${
string
}
"
)
"
=
''
]]
then
echo
'true'
else
echo
'false'
fi
}
#Project name
project
=
"restyaboard"
project_dir
=
"/var/www/"
#S3 info
S3KEY
=
"AKIAISAUYAT4BMFLKVFA"
S3SECRET
=
"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"
bucket
=
'vqode-clients-backups'
# Database credentials
user
=
${
MYSQL_USER
}
password
=
${
MYSQL_PASSWORD
}
host
=
${
MYSQL_HOST
}
db_name
=
${
MYSQL_DATABASE
}
# Email SMTP
mail_user
=
"no-reply@byghazala.com"
mail_password
=
"yVa1u1jlySUj"
mail_host
=
"mx.vqode.com"
mail_port
=
"25"
mail_to
=
"ali.arshad.gem@gmail.com"
# Other options
backup_path
=
"/var/www/dbBackups"
date
=
$(
date +
"%a-%d-%b-%Y-%T"
)
mkdir
-p
$backup_path
# Set default file permissions
umask
177
# Deleting old backups
find
$backup_path
/
*
-exec
rm
{}
\;
# Dump database into SQL file
echo
"Generating SQL Backup"
export
PGPASSWORD
=
"
$password
"
pg_dump
-U
$user
-h
$host
$db_name
>
$backup_path
/
$db_name
-
$date
.sql
# Delete files older than 30 days
# find $backup_path/* -mtime +30 -exec rm {} \;
#make the archive
echo
"Creating zip"
zip
-r
$project
-
$date
.zip
$project_dir
/
*
#Lets upload to s3
function
putS3
{
path
=
$1
file
=
$2
aws_path
=
$3
date_aws
=
$(
date +
"%a, %d %b %Y %T %z"
)
acl
=
"x-amz-acl:private"
content_type
=
'application/zip'
string
=
"PUT
\n\n
$content_type
\n
$date_aws
\n
$acl
\n
/
$bucket$aws_path$file
"
signature
=
$(
echo
-en
"
${
string
}
"
| openssl sha1
-hmac
"
${
S3SECRET
}
"
-binary
| base64
)
curl
-X
PUT
-T
"
$path
/
$file
"
\
-H
"Host:
$bucket
.s3.amazonaws.com"
\
-H
"Date:
$date_aws
"
\
-H
"Content-Type:
$content_type
"
\
-H
"
$acl
"
\
-H
"Authorization: AWS
${
S3KEY
}
:
$signature
"
\
"https://
$bucket
.s3.amazonaws.com
$aws_path$file
"
}
echo
"Uploading to S3"
putS3
"."
"
$project
-
$date
.zip"
"/backups/
$project
/"
#Lets generate signed URL
function
generateSignURL
()
{
awsAccessKeyID
=
${
S3KEY
}
awsSecretAccessKey
=
${
S3SECRET
}
region
=
"us-east-1"
local
-r
filePath
=
"
${
1
}
"
local
-r
method
=
"GET"
local
-r
minuteExpire
=
2880
if
[[
"
${
region
}
"
=
'us-east-1'
]]
then
region
=
''
fi
local
-r
endPoint
=
"
$(
"
$(
isEmptyString
"
${
region
}
"
)
"
=
'true'
&&
echo
's3.amazonaws.com'
||
echo
"s3-
${
region
}
.amazonaws.com"
)
"
local
-r
expire
=
"
$(($(
date +
'%s'
)
+
minuteExpire
*
60
))
"
local
-r
signature
=
"
$(
echo
-en
"
${
method
}
\n\n\n
${
expire
}
\n
/
${
bucket
}
/
${
filePath
}
"
|
openssl dgst
-sha1
-binary
-hmac
"
${
awsSecretAccessKey
}
"
|
openssl base64
)
"
local
-r
query
=
"AWSAccessKeyId=
$(
encodeURL
"
${
awsAccessKeyID
}
"
)
&Expires=
${
expire
}
&Signature=
$(
encodeURL
"
${
signature
}
"
)
"
signed_url
=
"https://
${
endPoint
}
/
${
bucket
}
/
${
filePath
}
?
${
query
}
"
}
generateSignURL
"backups/
$project
/
$project
-
$date
.zip"
#Lets remove the zip
echo
"Removing zip file"
rm
$project
-
$date
.zip
echo
"Sending notification email"
body
=
"Backup (
$project
-
$date
.zip) generated and uploaded to S3. Download link:
$signed_url
"
subject
=
"
$project
backup generated"
(
echo
$body
)
| mailx
-v
-s
"
$subject
"
-S
smtp-use-starttls
-S
smtp
=
"
$mail_host
:
$mail_port
"
-S
smtp-auth
=
"login"
-S
smtp-auth-user
=
$mail_user
-S
smtp-auth-password
=
$mail_password
-S
from
=
$mail_user
$mail_to
Dockerfile
→
Restyaboard/
Dockerfile
View file @
edc8e3df
FROM
alpine:3.5
FROM
alpine:3.5
ENV
RESTYABOARD_VERSION=v0.5 \
ENV
RESTYABOARD_VERSION=v0.
6.
5 \
ROOT_DIR=/usr/share/nginx/html \
ROOT_DIR=/usr/share/nginx/html \
CONF_DIR=/etc/nginx/conf.d \
CONF_DIR=/etc/nginx/conf.d \
SMTP_DOMAIN=localhost \
SMTP_DOMAIN=localhost \
...
...
docker-entrypoint.sh
→
Restyaboard/
docker-entrypoint.sh
View file @
edc8e3df
File moved
supervisord.conf
→
Restyaboard/
supervisord.conf
View file @
edc8e3df
File moved
docker-compose.yml
View file @
edc8e3df
version
:
'
2'
version
:
'
2'
services
:
services
:
restyaboard
:
restyaboard
:
build
:
.
build
:
.
/Restyaboard
ports
:
ports
:
-
1234
:80
-
40080
:80
volumes
:
volumes
:
-
/var/opt/restya/media:/usr/share/nginx/html/media
-
./media:/usr/share/nginx/html/media
links
:
-
postgres
environment
:
environment
:
-
POSTGRES_HOST=postgres
-
POSTGRES_HOST=postgres
-
POSTGRES_USER=admin
-
POSTGRES_USER=admin
-
POSTGRES_PASSWORD=
admin
-
POSTGRES_PASSWORD=
mXzon@9691
-
POSTGRES_DB=restyaboard
-
POSTGRES_DB=restyaboard
-
SMTP_DOMAIN=
domain
-
SMTP_DOMAIN=
gmail.com
-
SMTP_USERNAME=
user
-
SMTP_USERNAME=
vQodee@gmail.com
-
SMTP_PASSWORD=
pass
-
SMTP_PASSWORD=
aliarshad
-
SMTP_SERVER=s
erver
-
SMTP_SERVER=s
mtp.gmail.com
-
SMTP_PORT=465
-
SMTP_PORT=465
-
TZ=
Etc/UTC
-
TZ=
Asia/Karachi
depends_on
:
depends_on
:
-
postgres
-
postgres
restart
:
always
restart
:
always
postgres
:
postgres
:
image
:
kiasaki/alpine-
postgres
image
:
postgres
port
s
:
volume
s
:
-
5432:5432
-
./DB:/var/lib/postgresql/data
environment
:
environment
:
-
POSTGRES_HOST=postgres
-
POSTGRES_HOST=postgres
-
POSTGRES_USER=admin
-
POSTGRES_USER=admin
-
POSTGRES_PASSWORD=
admin
-
POSTGRES_PASSWORD=
mXzon@9691
-
POSTGRES_DB=restyaboard
-
POSTGRES_DB=restyaboard
restart
:
always
restart
:
always
cron
:
build
:
context
:
./BACKUP
depends_on
:
-
postgres
-
restyaboard
hostname
:
mail.vqode.com
links
:
-
postgres
volumes
:
-
./media:/var/www/html
environment
:
-
MYSQL_HOST=postgres
-
MYSQL_DATABASE=restyaboard
-
MYSQL_USER=admin
-
MYSQL_PASSWORD=mXzon@9691
restart
:
unless-stopped
container_name
:
restyaboard_backup_service
media/User/1/myPic.png
0 → 100644
View file @
edc8e3df
391 KB
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment