Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
freedombone
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Context Sensitive Group
freedombone
Commits
d27a518b
Commit
d27a518b
authored
8 years ago
by
Bob Mottram
Browse files
Options
Downloads
Patches
Plain Diff
Move remote gnusocial backup to app script
parent
7723c260
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/freedombone-app-gnusocial
+22
-2
22 additions, 2 deletions
src/freedombone-app-gnusocial
src/freedombone-backup-remote
+11
-91
11 additions, 91 deletions
src/freedombone-backup-remote
src/freedombone-utils-backup
+82
-0
82 additions, 0 deletions
src/freedombone-utils-backup
with
115 additions
and
93 deletions
src/freedombone-app-gnusocial
+
22
−
2
View file @
d27a518b
...
...
@@ -69,7 +69,7 @@ function gnusocial_running_script {
}
function
reconfigure_gnusocial
{
echo
-n
''
echo
-n
''
}
function
upgrade_gnusocial
{
...
...
@@ -139,7 +139,27 @@ function restore_local_gnusocial {
}
function
backup_remote_gnusocial
{
echo
-n
''
if
grep
-q
"GNU Social domain"
$COMPLETION_FILE
;
then
MICROBLOG_DOMAIN_NAME
=
$(
cat
$COMPLETION_FILE
|
grep
"GNU Social domain"
|
awk
-F
':'
'{print $2}'
)
temp_backup_dir
=
/var/www/
${
MICROBLOG_DOMAIN_NAME
}
/htdocs
if
[
-d
$temp_backup_dir
]
;
then
function_check suspend_site
suspend_site
${
MICROBLOG_DOMAIN_NAME
}
function_check backup_database_to_friend
backup_database_to_friend gnusocial
echo
$"Backing up GNU social installation"
function_check backup_directory_to_friend
backup_directory_to_friend
$temp_backup_dir
gnusocial
function_check restart_site
restart_site
else
echo
$"GNU Social domain specified but not found in
${
temp_backup_dir
}
"
fi
fi
}
function
restore_remote_gnusocial
{
...
...
This diff is collapsed.
Click to expand it.
src/freedombone-backup-remote
+
11
−
91
View file @
d27a518b
...
...
@@ -37,6 +37,12 @@ ENABLE_VERIFICATION="no"
export
TEXTDOMAIN
=
${
PROJECT_NAME
}
-backup-remote
export
TEXTDOMAINDIR
=
"/usr/share/locale"
UTILS_FILES
=
/usr/share/
${
PROJECT_NAME
}
/utils/
${
PROJECT_NAME
}
-utils-
*
for
f
in
$UTILS_FILES
do
source
$f
done
# Temporary location for data to be backed up to other servers
SERVER_DIRECTORY
=
/root/remotebackup
...
...
@@ -94,77 +100,6 @@ function restart_site {
SUSPENDED_SITE
=
}
function
backup_directory_to_friend
{
BACKUP_KEY_EXISTS
=
$(
gpg
--list-keys
"
$ADMIN_NAME
(backup key)"
)
if
[
!
"
$?
"
=
"0"
]
;
then
echo
$"Backup key could not be found"
restart_site
exit
43382
fi
ADMIN_BACKUP_KEY_ID
=
$(
gpg
--list-keys
"
$ADMIN_NAME
(backup key)"
|
grep
'pub '
|
awk
-F
' '
'{print $2}'
|
awk
-F
'/'
'{print $2}'
)
if
[
!
-d
$SERVER_DIRECTORY
/backup/
${
2
}
]
;
then
mkdir
-p
$SERVER_DIRECTORY
/backup/
${
2
}
fi
obnam force-lock
-r
$SERVER_DIRECTORY
/backup/
${
2
}
--encrypt-with
${
ADMIN_BACKUP_KEY_ID
}
${
1
}
obnam backup
-r
$SERVER_DIRECTORY
/backup/
${
2
}
--encrypt-with
${
ADMIN_BACKUP_KEY_ID
}
${
1
}
if
[[
$ENABLE_VERIFICATION
==
"yes"
]]
;
then
obnam verify
-r
$SERVER_DIRECTORY
/backup/
${
2
}
--encrypt-with
${
ADMIN_BACKUP_KEY_ID
}
${
1
}
if
[
!
"
$?
"
=
"0"
]
;
then
if
[[
${
1
}
==
"/root/temp"
*
||
${
1
}
==
*
"tempbackup"
]]
;
then
shred
-zu
/root/temp
${
2
}
/
*
rm
-rf
/root/temp
${
2
}
fi
# Send a warning email
echo
"Unable to verify
${
2
}
"
| mail
-s
"
${
PROJECT_NAME
}
backup to friends"
${
ADMIN_EMAIL_ADDRESS
}
restart_site
exit
953
fi
fi
obnam forget
--keep
=
30d
-r
$SERVER_DIRECTORY
/backup/
${
2
}
--encrypt-with
${
ADMIN_BACKUP_KEY_ID
}
if
[
!
"
$?
"
=
"0"
]
;
then
if
[[
${
1
}
==
"/root/temp"
*
||
${
1
}
==
*
"tempbackup"
]]
;
then
shred
-zu
/root/temp
${
2
}
/
*
rm
-rf
/root/temp
${
2
}
fi
# Send a warning email
echo
"Unable to backup
${
2
}
"
| mail
-s
"
${
PROJECT_NAME
}
backup to friends"
${
ADMIN_EMAIL_ADDRESS
}
restart_site
exit
853
fi
if
[[
${
1
}
==
"/root/temp"
*
||
${
1
}
==
*
"tempbackup"
]]
;
then
shred
-zu
/root/temp
${
2
}
/
*
rm
-rf
/root/temp
${
2
}
fi
}
function
backup_database_to_friend
{
if
[
${#
DATABASE_PASSWORD
}
-lt
2
]
;
then
echo
$"No MariaDB password was given"
restart_site
exit
5783
fi
if
[
!
-d
$SERVER_DIRECTORY
/backup/
${
1
}
]
;
then
mkdir
-p
$SERVER_DIRECTORY
/backup/
${
1
}
fi
if
[
!
-d
$SERVER_DIRECTORY
/backup/
${
1
}
data
]
;
then
mkdir
-p
$SERVER_DIRECTORY
/backup/
${
1
}
data
fi
if
[
!
-d
/root/temp
${
1
}
data
]
;
then
mkdir
-p
/root/temp
${
1
}
data
fi
echo
"Obtaining
${
1
}
database backup"
mysqldump
--password
=
$DATABASE_PASSWORD
${
1
}
>
/root/temp
${
1
}
data/
${
1
}
.sql
if
[
!
-s
/root/temp
${
1
}
data/
${
1
}
.sql
]
;
then
echo
$"
${
1
}
database could not be saved"
shred
-zu
/root/temp
${
1
}
data/
*
rm
-rf
/root/temp
${
1
}
data
# Send a warning email
echo
$"Unable to export
${
1
}
database"
| mail
-s
$"
${
PROJECT_NAME
}
backup to friends"
$ADMIN_EMAIL_ADDRESS
restart_site
exit
5738
fi
}
function
backup_configuration
{
echo
$"Backing up
${
PROJECT_NAME
}
configuration files"
if
[
!
-d
/root/tempbackupconfig
]
;
then
...
...
@@ -325,22 +260,6 @@ function backup_rss {
fi
}
function
backup_gnusocial
{
if
grep
-q
"GNU Social domain"
$COMPLETION_FILE
;
then
MICROBLOG_DOMAIN_NAME
=
$(
cat
$COMPLETION_FILE
|
grep
"GNU Social domain"
|
awk
-F
':'
'{print $2}'
)
if
[
-d
/var/www/
${
MICROBLOG_DOMAIN_NAME
}
/htdocs
]
;
then
suspend_site
${
MICROBLOG_DOMAIN_NAME
}
backup_database_to_friend gnusocial
backup_directory_to_friend /root/tempgnusocialdata gnusocialdata
echo
$"Backing up GNU social installation"
backup_directory_to_friend /var/www/
${
MICROBLOG_DOMAIN_NAME
}
/htdocs gnusocial
restart_site
else
echo
$"GNU Social domain specified but not found in /var/www/
${
MICROBLOG_DOMAIN_NAME
}
"
fi
fi
}
function
backup_hubzilla
{
if
grep
-q
"Hubzilla domain"
$COMPLETION_FILE
;
then
HUBZILLA_DOMAIN_NAME
=
$(
cat
$COMPLETION_FILE
|
grep
"Hubzilla domain"
|
awk
-F
':'
'{print $2}'
)
...
...
@@ -645,7 +564,10 @@ if [[ $TEST_MODE == "no" ]]; then
backup_users
backup_letsencrypt
backup_tor
backup_gnusocial
backup_web_server
backup_admin_readme
backup_mariadb
backup_rss
backup_hubzilla
backup_syncthing
...
...
@@ -656,13 +578,11 @@ if [[ $TEST_MODE == "no" ]]; then
backup_certs
backup_mailing_list
backup_xmpp
backup_web_server
backup_admin_readme
backup_ipfs
backup_dlna
backup_voip
backup_tox
backup_mariadb
backup_extra_directories
fi
...
...
This diff is collapsed.
Click to expand it.
src/freedombone-utils-backup
+
82
−
0
View file @
d27a518b
...
...
@@ -281,4 +281,86 @@ function set_user_permissions {
done
}
function
backup_directory_to_friend
{
BACKUP_KEY_EXISTS
=
$(
gpg
--list-keys
"
$ADMIN_NAME
(backup key)"
)
if
[
!
"
$?
"
=
"0"
]
;
then
echo
$"Backup key could not be found"
function_check restart_site
restart_site
exit
43382
fi
ADMIN_BACKUP_KEY_ID
=
$(
gpg
--list-keys
"
$ADMIN_NAME
(backup key)"
|
grep
'pub '
|
awk
-F
' '
'{print $2}'
|
awk
-F
'/'
'{print $2}'
)
if
[
!
-d
$SERVER_DIRECTORY
/backup/
${
2
}
]
;
then
mkdir
-p
$SERVER_DIRECTORY
/backup/
${
2
}
fi
obnam force-lock
-r
$SERVER_DIRECTORY
/backup/
${
2
}
--encrypt-with
${
ADMIN_BACKUP_KEY_ID
}
${
1
}
obnam backup
-r
$SERVER_DIRECTORY
/backup/
${
2
}
--encrypt-with
${
ADMIN_BACKUP_KEY_ID
}
${
1
}
if
[[
$ENABLE_VERIFICATION
==
"yes"
]]
;
then
obnam verify
-r
$SERVER_DIRECTORY
/backup/
${
2
}
--encrypt-with
${
ADMIN_BACKUP_KEY_ID
}
${
1
}
if
[
!
"
$?
"
=
"0"
]
;
then
if
[[
${
1
}
==
"/root/temp"
*
||
${
1
}
==
*
"tempbackup"
]]
;
then
shred
-zu
/root/temp
${
2
}
/
*
rm
-rf
/root/temp
${
2
}
fi
# Send a warning email
echo
"Unable to verify
${
2
}
"
| mail
-s
"
${
PROJECT_NAME
}
backup to friends"
${
ADMIN_EMAIL_ADDRESS
}
function_check restart_site
restart_site
exit
953
fi
fi
obnam forget
--keep
=
30d
-r
$SERVER_DIRECTORY
/backup/
${
2
}
--encrypt-with
${
ADMIN_BACKUP_KEY_ID
}
if
[
!
"
$?
"
=
"0"
]
;
then
if
[[
${
1
}
==
"/root/temp"
*
||
${
1
}
==
*
"tempbackup"
]]
;
then
shred
-zu
/root/temp
${
2
}
/
*
rm
-rf
/root/temp
${
2
}
fi
# Send a warning email
echo
"Unable to backup
${
2
}
"
| mail
-s
"
${
PROJECT_NAME
}
backup to friends"
${
ADMIN_EMAIL_ADDRESS
}
function_check restart_site
restart_site
exit
853
fi
if
[[
${
1
}
==
"/root/temp"
*
||
${
1
}
==
*
"tempbackup"
]]
;
then
shred
-zu
/root/temp
${
2
}
/
*
rm
-rf
/root/temp
${
2
}
fi
}
function
backup_database_remote
{
if
[
${#
DATABASE_PASSWORD
}
-lt
2
]
;
then
echo
$"No MariaDB password was given"
function_check restart_site
restart_site
exit
5783
fi
if
[
!
-d
$SERVER_DIRECTORY
/backup/
${
1
}
]
;
then
mkdir
-p
$SERVER_DIRECTORY
/backup/
${
1
}
fi
if
[
!
-d
$SERVER_DIRECTORY
/backup/
${
1
}
data
]
;
then
mkdir
-p
$SERVER_DIRECTORY
/backup/
${
1
}
data
fi
if
[
!
-d
/root/temp
${
1
}
data
]
;
then
mkdir
-p
/root/temp
${
1
}
data
fi
echo
"Obtaining
${
1
}
database backup"
mysqldump
--password
=
$DATABASE_PASSWORD
${
1
}
>
/root/temp
${
1
}
data/
${
1
}
.sql
if
[
!
-s
/root/temp
${
1
}
data/
${
1
}
.sql
]
;
then
echo
$"
${
1
}
database could not be saved"
shred
-zu
/root/temp
${
1
}
data/
*
rm
-rf
/root/temp
${
1
}
data
# Send a warning email
echo
$"Unable to export
${
1
}
database"
| mail
-s
$"
${
PROJECT_NAME
}
backup to friends"
$ADMIN_EMAIL_ADDRESS
function_check restart_site
restart_site
exit
5738
fi
}
function
backup_database_to_friend
{
database_name
=
$1
backup_database_remote
$database_name
backup_directory_to_friend /root/temp
${
database_name
}
data
${
database_name
}
data
}
# NOTE: deliberately no exit 0
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment