Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
nk20-scripts
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
BDE
nk20-scripts
Commits
b311d7d5
Commit
b311d7d5
authored
4 years ago
by
ynerant
Browse files
Options
Downloads
Patches
Plain Diff
➕
Backup database script
parent
a66ce1ad
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
shell/backup_db
+11
-0
11 additions, 0 deletions
shell/backup_db
with
11 additions
and
0 deletions
shell/backup_db
0 → 100755
+
11
−
0
View file @
b311d7d5
#!/bin/bash
# Create backups directory
[[
-d
/var/www/note_kfet/backups
]]
||
(
mkdir
/var/www/note_kfet/backups
&&
chown
www-data:www-data /var/www/note_kfet/backups
)
date
=
$(
date
+%Y-%m-%d
)
# Backup database and save it as tar archive
su postgres
-c
"pg_dump -F t note_db"
|
tee
"/var/www/note_kfet/backups/
$date
.tar"
>
/dev/null
# Compress backup as gzip
gzip
"/var/www/note_kfet/backups/
$date
.tar"
chown
www-data:www-data
"/var/www/note_kfet/backups/
$date
.tar.gz"
# Delete backups that have more than 30 days
find /var/www/note_kfet/backups
-type
f
-mtime
+30
-exec
rm
{}
\;
\ No newline at end of file
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