Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
haskell-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Christian Merten
haskell-gargantext
Commits
339de564
Commit
339de564
authored
Jul 21, 2022
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ADMIN] bash scripts to enter or backup a postgres database
parent
f940f13a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
5 deletions
+40
-5
backup
bin/backup
+28
-0
psql
bin/psql
+12
-5
No files found.
bin/backup
0 → 100755
View file @
339de564
#!/bin/bash
# 0 3 * * * pg_dump --dbname=$MYDB | gzip > ~/backup/db/$(date +%Y-%m-%d).psql.gz
if
[[
$1
==
""
||
$2
==
""
]]
then
echo
"USAGE : ./psql gargantext.ini backup_directory"
else
INIFILE
=
$1
getter
()
{
grep
$1
$INIFILE
|
sed
"s/^.*= //"
}
USER
=
$(
getter
"DB_USER"
)
NAME
=
$(
getter
"DB_NAME"
)
PASS
=
$(
getter
"DB_PASS"
)
HOST
=
$(
getter
"DB_HOST"
)
PORT
=
$(
getter
"DB_PORT"
)
GARGDB
=
"postgresql://
${
USER
}
:
${
PASS
}
@
${
HOST
}
:
${
PORT
}
/
${
NAME
}
"
#echo "backuping $GARGDB"
pg_dump
--dbname
=
$GARGDB
|
gzip
>
$2
/
$(
date
+%Y-%m-%d
)
.garg_dump.gz
fi
bin/psql
View file @
339de564
#!/bin/bash
if
[[
$1
==
""
]]
then
echo
"USAGE : ./psql gargantext.ini"
else
INIFILE
=
$1
getter
()
{
grep
$1
$INIFILE
|
sed
"s/^.*= //"
}
connect
()
{
USER
=
$(
getter
"DB_USER"
)
NAME
=
$(
getter
"DB_NAME"
)
PASS
=
$(
getter
"DB_PASS"
)
HOST
=
$(
getter
"DB_HOST"
)
PORT
=
$(
getter
"DB_PORT"
)
# "postgresql://${USER}:${PASS}@${HOST}:${PORT}/${NAME}"
GARGDB
=
"postgresql://
${
USER
}
:
${
PASS
}
@
${
HOST
}
:
${
PORT
}
/
${
NAME
}
"
#echo "connecting to $GARGDB"
psql
"postgresql://
${
USER
}
:
${
PASS
}
@
${
HOST
}
:
${
PORT
}
/
${
NAME
}
"
}
if
[[
$1
==
""
]]
then
echo
"USAGE : ./psql gargantext.ini"
else
connect
$INIFILE
fi
...
...
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