aboutsummaryrefslogtreecommitdiff
path: root/content/resources
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@chimrod.com>2021-11-18 15:14:25 +0100
committerSébastien Dailly <sebastien@dailly.me>2022-02-01 18:38:01 +0100
commit4074d0a6adbdef0591578f477d9068a07ba5fd94 (patch)
tree0e971bd4ac93c09b5f3879c859f36732a6f13c77 /content/resources
parent3dfa4d20256ca7f8599f1999956b3721942b2184 (diff)
Sauvegardes avec duplicity
Diffstat (limited to 'content/resources')
-rw-r--r--content/resources/backup.sh100
-rwxr-xr-xcontent/resources/backup/gen_config.sh88
-rwxr-xr-xcontent/resources/backup/gen_config_local.sh58
3 files changed, 146 insertions, 100 deletions
diff --git a/content/resources/backup.sh b/content/resources/backup.sh
deleted file mode 100644
index aaf16f4..0000000
--- a/content/resources/backup.sh
+++ /dev/null
@@ -1,100 +0,0 @@
-#!/bin/sh
-###########################################################
-# This script uses rsync to backup directories on a media
-# (ex: USB disk) with a copy and incremental method.
-###########################################################
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-############################################################
-#
-# Written by Spip
-# Adapted by Chimrod
-# added script path detection
-# delete with find
-# Version 1.0
-#
-############################################################
-#to be nice...
-ionice -c3 -p$$
-renice +15 -p $$
-THEDATE=`date +%F_%Hh%M`
-#FILE=`dirname $0`
-FILE=`dirname "$(cd "${0%/*}" 2>/dev/null; echo "$PWD"/"${0##*/}")"`
-LOGFILE=$FILE'/log/sauvegarde'
-
-SPLIT='====================================================================='
-#check logfile directory
-
-if ! [ -e $LOGFILE ]
-then
- /bin/mkdir -p $LOGFILE
-fi
-
-#check if the media is mounted
-
-if ! [ -e $FILE ]
-then
- echo "$THEDATE : péripherique non connecté. Pas de sauvegarde possible" >> "$LOGFILE/save.log"
- echo $SPLIT >> "$LOGFILE/save.log"
- exit 0
-fi
-
-#prevent a second task
-LOCKFILE="/var/lock/sauvegarde.lock"
-[ -f $LOCKFILE ] && exit 0
-
-#if the script are stoped, remove lockfile
-trap "rm -f $LOCKFILE" EXIT
-touch $LOCKFILE
-echo "$THEDATE : Début de sauvegarde" >> "$LOGFILE/save.log"
-# $1:time to keep files; $2: name of the backup; $3: target
-
-function save() {
-
- echo "$SPLIT" >> "$LOGFILE/$2.log"
- echo "$THEDATE" >> "$LOGFILE/$2.log"
-
- #Incremental & copie
- INC="$FILE/$2/INC/$THEDATE"
- BAK="$FILE/$2/BAK"
- TOSAVE="$3"
- mkdir -p $INC
-
- if ! [ -e "$BAK" ]
- then
- /bin/mkdir -p "$BAK"
- fi
-
- #a: archivage :recurcif, preserve dates, persmissions, groupes...
- #v: verbose mode
- #delete : supprime les fichiers n'etant plus chez l'émeteur >> copie conforme.
- /usr/bin/rsync -a --stats --delete --backup --backup-dir="$INC" "$TOSAVE" "$BAK" >> "$LOGFILE/$2.log"
-
- cd $FILE/$2/INC
- tar -czvf "$INC.tar.gz" "$THEDATE"
- echo tar -czvf "$INC.tar.gz" "$FILE/$2/INC/$THEDATE"
- rm -rf "$THEDATE"
- #Remove the file older than $1 days
- find "$FILE/$2/INC" -mtime +$1 -delete >> "$LOGFILE/save.log"
-
-}
-
-#List here all repositories to backup
-
-save 90 etc /etc/
-
-#to log the end of the backup
-THEDATE=`date +%F_%Hh%M`
-echo "$THEDATE : Sauvegarde effectuée" >> "$LOGFILE/save.log"
-exit 0
diff --git a/content/resources/backup/gen_config.sh b/content/resources/backup/gen_config.sh
new file mode 100755
index 0000000..8091bed
--- /dev/null
+++ b/content/resources/backup/gen_config.sh
@@ -0,0 +1,88 @@
+#!/bin/bash
+
+. ./$1
+OUTFILE=$2
+BACKUP_NAME=$3
+
+if test "x${PCA_OS_REGION_NAME}" = x; then
+ PCA_OS_REGION_NAME=${OS_REGION_NAME}
+fi
+
+if test "x${HOT_OS_REGION_NAME}" = x; then
+ HOT_OS_REGION_NAME=${OS_REGION_NAME}
+fi
+
+envsubst > "${OUTFILE}" << EOF
+[
+ {
+ "description": "Cold storage",
+ "url": "pca://${BACKUP_NAME}",
+ "env": [
+ {
+ "name": "PCA_AUTHURL",
+ "value": "${OS_AUTH_URL}"
+ },
+ {
+ "name": "PCA_AUTHVERSION",
+ "value": "${OS_IDENTITY_API_VERSION}"
+ },
+ {
+ "name": "PCA_PROJECT_DOMAIN_NAME",
+ "value": "Default"
+ },
+ {
+ "name": "PCA_TENANTID",
+ "value": "${OS_TENANT_ID}"
+ },
+ {
+ "name": "PCA_USERNAME",
+ "value": "${OS_USERNAME}"
+ },
+ {
+ "name": "PCA_PASSWORD",
+ "value": "${OS_PASSWORD}"
+ },
+ {
+ "name": "PCA_REGIONNAME",
+ "value": "${PCA_OS_REGION_NAME}"
+ }
+ ],
+ "prefixes": ["cold_"]
+ },
+ {
+ "description": "Hot storage",
+ "url": "swift://${BACKUP_NAME}_indexes",
+ "env": [
+ {
+ "name": "SWIFT_AUTHURL",
+ "value": "${OS_AUTH_URL}"
+ },
+ {
+ "name": "SWIFT_AUTHVERSION",
+ "value": "${OS_IDENTITY_API_VERSION}"
+ },
+ {
+ "name": "SWIFT_PROJECT_DOMAIN_NAME",
+ "value": "${OS_PROJECT_DOMAIN_NAME}"
+ },
+ {
+ "name": "SWIFT_TENANTID",
+ "value": "${OS_TENANT_ID}"
+ },
+ {
+ "name": "SWIFT_USERNAME",
+ "value": "${OS_USERNAME}"
+ },
+ {
+ "name": "SWIFT_PASSWORD",
+ "value": "${OS_PASSWORD}"
+ },
+ {
+ "name": "SWIFT_REGIONNAME",
+ "value": "${HOT_OS_REGION_NAME}"
+ }
+ ],
+ "prefixes": ["hot_"]
+ }
+]
+EOF
diff --git a/content/resources/backup/gen_config_local.sh b/content/resources/backup/gen_config_local.sh
new file mode 100755
index 0000000..4e6c0dc
--- /dev/null
+++ b/content/resources/backup/gen_config_local.sh
@@ -0,0 +1,58 @@
+#!/bin/bash
+
+. ./$1
+OUTFILE=$2
+BACKUP_NAME=$3
+
+if test "x${PCA_OS_REGION_NAME}" = x; then
+ PCA_OS_REGION_NAME=${OS_REGION_NAME}
+fi
+
+if test "x${HOT_OS_REGION_NAME}" = x; then
+ HOT_OS_REGION_NAME=${OS_REGION_NAME}
+fi
+
+envsubst > "${OUTFILE}" << EOF
+[
+ {
+ "description": "Cold storage",
+ "url": "file://${BACKUP_NAME}",
+ "prefixes": ["cold_"]
+ },
+ {
+ "description": "Hot storage",
+ "url": "swift://${BACKUP_NAME}_indexes",
+ "env": [
+ {
+ "name": "SWIFT_AUTHURL",
+ "value": "${OS_AUTH_URL}"
+ },
+ {
+ "name": "SWIFT_AUTHVERSION",
+ "value": "${OS_IDENTITY_API_VERSION}"
+ },
+ {
+ "name": "SWIFT_PROJECT_DOMAIN_NAME",
+ "value": "${OS_PROJECT_DOMAIN_NAME}"
+ },
+ {
+ "name": "SWIFT_TENANTID",
+ "value": "${OS_TENANT_ID}"
+ },
+ {
+ "name": "SWIFT_USERNAME",
+ "value": "${OS_USERNAME}"
+ },
+ {
+ "name": "SWIFT_PASSWORD",
+ "value": "${OS_PASSWORD}"
+ },
+ {
+ "name": "SWIFT_REGIONNAME",
+ "value": "${HOT_OS_REGION_NAME}"
+ }
+ ],
+ "prefixes": ["hot_"]
+ }
+]
+EOF