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
6b287ba0
Unverified
Commit
6b287ba0
authored
8 years ago
by
Bob Mottram
Browse files
Options
Downloads
Patches
Plain Diff
Emacs placeholders
parent
6beae8d5
No related branches found
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-emacs
+3
-3
3 additions, 3 deletions
src/freedombone-app-emacs
src/freedombone-backup-local
+3
-63
3 additions, 63 deletions
src/freedombone-backup-local
src/freedombone-utils-backup
+66
-0
66 additions, 0 deletions
src/freedombone-utils-backup
with
72 additions
and
66 deletions
src/freedombone-app-emacs
+
3
−
3
View file @
6b287ba0
...
...
@@ -31,15 +31,15 @@
VARIANTS
=
'all'
function
upgrade_emacs
{
echo
''
echo
-n
''
}
function
backup_local_emacs
{
echo
''
echo
-n
''
}
function
backup_remote_emacs
{
echo
''
echo
-n
''
}
function
remove_emacs
{
...
...
This diff is collapsed.
Click to expand it.
src/freedombone-backup-local
+
3
−
63
View file @
6b287ba0
...
...
@@ -97,66 +97,6 @@ function update_domains {
fi
}
function
mount_drive
{
if
[
$1
]
;
then
USB_DRIVE
=
/dev/
${
1
}
1
fi
# get the admin user
ADMIN_USERNAME
=
$(
cat
$COMPLETION_FILE
|
grep
"Admin user"
|
awk
-F
':'
'{print $2}'
)
if
[
$2
]
;
then
ADMIN_USERNAME
=
$2
fi
ADMIN_NAME
=
$(
getent passwd
$ADMIN_USERNAME
|
cut
-d
:
-f5
|
cut
-d
,
-f1
)
# check that the backup destination is available
if
[
!
-b
$USB_DRIVE
]
;
then
echo
$"Please attach a USB drive"
exit
1
fi
# unmount if already mounted
umount
-f
$USB_MOUNT
if
[
!
-d
$USB_MOUNT
]
;
then
mkdir
$USB_MOUNT
fi
if
[
-f
/dev/mapper/encrypted_usb
]
;
then
rm
-rf
/dev/mapper/encrypted_usb
fi
cryptsetup luksClose encrypted_usb
# mount the encrypted backup drive
cryptsetup luksOpen
$USB_DRIVE
encrypted_usb
if
[
"
$?
"
=
"0"
]
;
then
USB_DRIVE
=
/dev/mapper/encrypted_usb
fi
mount
$USB_DRIVE
$USB_MOUNT
if
[
!
"
$?
"
=
"0"
]
;
then
echo
$"There was a problem mounting the USB drive to
$USB_MOUNT
"
rm
-rf
$USB_MOUNT
exit
2
fi
}
function
unmount_drive
{
sync
umount
$USB_MOUNT
if
[
!
"
$?
"
=
"0"
]
;
then
echo
$"Unable to unmount the drive. This means that the backup did not work"
rm
-rf
$USB_MOUNT
exit
9
fi
rm
-rf
$USB_MOUNT
if
[[
$USB_DRIVE
==
/dev/mapper/encrypted_usb
]]
;
then
echo
$"Unmount encrypted USB"
cryptsetup luksClose encrypted_usb
fi
if
[
-f
/dev/mapper/encrypted_usb
]
;
then
rm
-rf
/dev/mapper/encrypted_usb
fi
echo
$"Backup to USB drive is complete. You can now unplug it."
}
function
backup_database
{
if
[
${#
DATABASE_PASSWORD
}
-lt
2
]
;
then
echo
$"No MariaDB password was given"
...
...
@@ -452,7 +392,7 @@ function remove_backup_directory {
if
[
-d
$USB_MOUNT
/backup
]
;
then
rm
-rf
$USB_MOUNT
/backup
echo
$'Existing backup directory removed'
unmount_drive
backup_
unmount_drive
exit
0
fi
fi
...
...
@@ -603,7 +543,7 @@ if [[ $1 == "remove" ]]; then
remove_option
=
$1
fi
mount_drive
$1
$2
backup_
mount_drive
$1
$2
remove_backup_directory
$remove_option
make_backup_directory
check_storage_space_remaining
...
...
@@ -616,6 +556,6 @@ backup_admin_readme
backup_voip
backup_mariadb
backup_extra_directories
unmount_drive
backup_
unmount_drive
$USB_DRIVE
$USB_MOUNT
exit
0
This diff is collapsed.
Click to expand it.
src/freedombone-utils-backup
+
66
−
0
View file @
6b287ba0
...
...
@@ -96,4 +96,70 @@ function backup_to_friends_servers {
chmod
+x /etc/cron.daily/backuptofriends
}
function
backup_mount_drive
{
if
[
$1
]
;
then
USB_DRIVE
=
/dev/
${
1
}
1
fi
# get the admin user
ADMIN_USERNAME
=
$(
cat
$COMPLETION_FILE
|
grep
"Admin user"
|
awk
-F
':'
'{print $2}'
)
if
[
$2
]
;
then
ADMIN_USERNAME
=
$2
fi
ADMIN_NAME
=
$(
getent passwd
$ADMIN_USERNAME
|
cut
-d
:
-f5
|
cut
-d
,
-f1
)
# check that the backup destination is available
if
[
!
-b
$USB_DRIVE
]
;
then
echo
$"Please attach a USB drive"
exit
1
fi
# unmount if already mounted
umount
-f
$USB_MOUNT
if
[
!
-d
$USB_MOUNT
]
;
then
mkdir
$USB_MOUNT
fi
if
[
-f
/dev/mapper/encrypted_usb
]
;
then
rm
-rf
/dev/mapper/encrypted_usb
fi
cryptsetup luksClose encrypted_usb
# mount the encrypted backup drive
cryptsetup luksOpen
$USB_DRIVE
encrypted_usb
if
[
"
$?
"
=
"0"
]
;
then
USB_DRIVE
=
/dev/mapper/encrypted_usb
fi
mount
$USB_DRIVE
$USB_MOUNT
if
[
!
"
$?
"
=
"0"
]
;
then
echo
$"There was a problem mounting the USB drive to
$USB_MOUNT
"
rm
-rf
$USB_MOUNT
exit
783452
fi
}
function
backup_unmount_drive
{
if
[
$1
]
;
then
USB_DRIVE
=
${
1
}
if
[
$2
]
;
then
USB_MOUNT
=
${
2
}
fi
fi
sync
umount
$USB_MOUNT
if
[
!
"
$?
"
=
"0"
]
;
then
echo
$"Unable to unmount the drive. This means that the backup did not work"
rm
-rf
$USB_MOUNT
exit
9
fi
rm
-rf
$USB_MOUNT
if
[[
$USB_DRIVE
==
/dev/mapper/encrypted_usb
]]
;
then
echo
$"Unmount encrypted USB"
cryptsetup luksClose encrypted_usb
fi
if
[
-f
/dev/mapper/encrypted_usb
]
;
then
rm
-rf
/dev/mapper/encrypted_usb
fi
echo
$"Backup to USB drive is complete. You can now unplug it."
}
# 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