summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.profile5
-rwxr-xr-xscripts/backup/docker_volumes_backup.sh11
-rwxr-xr-xscripts/backup/postgres_backup_v1.sh31
-rwxr-xr-xscripts/backup/postgres_backup_v2.sh16
-rwxr-xr-xscripts/install_docker.sh (renamed from install_docker.sh)0
-rwxr-xr-xscripts/package_sync.sh (renamed from package_sync.sh)0
-rwxr-xr-xscripts/setup_fail2ban.sh (renamed from setup_fail2ban.sh)0
-rwxr-xr-xscripts/setup_ufw.sh (renamed from setup_ufw.sh)0
-rwxr-xr-x[-rw-r--r--]scripts/utils/create_docker_network (renamed from bin/create_docker_network)1
-rwxr-xr-x[-rw-r--r--]scripts/utils/create_docker_volume (renamed from bin/create_docker_volume)1
10 files changed, 63 insertions, 2 deletions
diff --git a/.profile b/.profile
index 0a8defc..db55de6 100644
--- a/.profile
+++ b/.profile
@@ -1,5 +1,5 @@
-if [ -d "$HOME/bin" ] ; then
- PATH="$HOME/bin:$PATH"
+if [ -d "$HOME/scripts/utils" ] ; then
+ PATH="$HOME/scripts/utils:$PATH"
fi
if [ "$BASH" ]; then
@@ -7,4 +7,5 @@ if [ "$BASH" ]; then
. ~/.bashrc
fi
fi
+
mesg n 2> /dev/null || true
diff --git a/scripts/backup/docker_volumes_backup.sh b/scripts/backup/docker_volumes_backup.sh
new file mode 100755
index 0000000..403c745
--- /dev/null
+++ b/scripts/backup/docker_volumes_backup.sh
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+set -Eeuo pipefail
+
+volumes_path="/var/lib/docker/volumes"
+backup_folder="/opt/backup/docker_data"
+filename="$(date -u +%Y%m%dT%H%M%SZ).tar"
+
+[ ! -d $backup_folder ] && mkdir -p $backup_folder
+
+tar cvf $backup_folder/$filename $volumes_path
diff --git a/scripts/backup/postgres_backup_v1.sh b/scripts/backup/postgres_backup_v1.sh
new file mode 100755
index 0000000..10f3b30
--- /dev/null
+++ b/scripts/backup/postgres_backup_v1.sh
@@ -0,0 +1,31 @@
+#!/bin/bash
+
+set -Eeuo pipefail
+
+host="localhost"
+port="5432"
+user="postgres"
+databases=("vsh_store" "time_tracker")
+backup_name=$(date -u +%Y%m%dT%H%M%SZ)
+backup_folder=/opt/backup/db
+
+for i in "${databases[@]}"
+do
+
+ pushd $backup_folder
+
+ if [ ! -d "$i" ]; then
+ mkdir -p $i
+ fi
+
+ cd $i
+
+ echo "$(date -u +%Y-%m-%d_%H:%M:%SZ) Dumping $i into $backup_folder/$i/$backup_name.psql"
+ pg_dump -U $user -p $port -h $host -Fc --clean --if-exists $i -f $backup_name.psql
+
+ echo "$(date -u +%Y-%m-%d_%H:%M:%SZ) Dumping $i into $backup_folder/$i/$backup_name.sql"
+ pg_dump -U $user -p $port -h $host --inserts --clean --if-exists $i -f $backup_name.sql
+
+ popd
+
+done
diff --git a/scripts/backup/postgres_backup_v2.sh b/scripts/backup/postgres_backup_v2.sh
new file mode 100755
index 0000000..1f06514
--- /dev/null
+++ b/scripts/backup/postgres_backup_v2.sh
@@ -0,0 +1,16 @@
+#!/bin/bash
+
+set -Eeuo pipefail
+
+backup_folder="/opt/backup/db/$(date -u +%F)"
+postgres_host="127.0.0.1"
+postgres_port="5432"
+filename="$(date -u +%H%M%S).psqldump"
+
+[ ! -d $backup_folder ] && mkdir -p $backup_folder
+
+pushd $backup_folder
+
+pg_dumpall --host=$postgres_host --port=$postgres_port -U postgres --clean --if-exists -f $filename
+
+popd
diff --git a/install_docker.sh b/scripts/install_docker.sh
index 56594ba..56594ba 100755
--- a/install_docker.sh
+++ b/scripts/install_docker.sh
diff --git a/package_sync.sh b/scripts/package_sync.sh
index 44583f0..44583f0 100755
--- a/package_sync.sh
+++ b/scripts/package_sync.sh
diff --git a/setup_fail2ban.sh b/scripts/setup_fail2ban.sh
index b817ee6..b817ee6 100755
--- a/setup_fail2ban.sh
+++ b/scripts/setup_fail2ban.sh
diff --git a/setup_ufw.sh b/scripts/setup_ufw.sh
index 0fead6f..0fead6f 100755
--- a/setup_ufw.sh
+++ b/scripts/setup_ufw.sh
diff --git a/bin/create_docker_network b/scripts/utils/create_docker_network
index 1e55846..861ce22 100644..100755
--- a/bin/create_docker_network
+++ b/scripts/utils/create_docker_network
@@ -1,2 +1,3 @@
#!/bin/bash
+
sudo docker network create -d bridge $1
diff --git a/bin/create_docker_volume b/scripts/utils/create_docker_volume
index 74e1192..62a27cd 100644..100755
--- a/bin/create_docker_volume
+++ b/scripts/utils/create_docker_volume
@@ -1,3 +1,4 @@
#!/bin/bash
+
sudo mkdir /var/opt/$1
sudo docker volume create --driver local --opt type=none --opt device=/var/opt/$1 --opt o=bind $1