Compare commits

..

2 Commits

Author SHA1 Message Date
wpetit debd11ab6f Fix links 2020-10-13 15:46:07 +02:00
wpetit 28c1f6528c Add debian packaging files 2020-10-13 15:37:16 +02:00
15 changed files with 56 additions and 124 deletions

1
.gitignore vendored
View File

@ -1 +0,0 @@
/dist

49
Jenkinsfile vendored
View File

@ -1,49 +0,0 @@
@Library('cadoles') _
pipeline {
agent {
dockerfile {
label 'docker'
filename 'Dockerfile'
dir 'misc/ci'
}
}
stages {
stage('Build and publish packages') {
when {
anyOf {
branch 'master'
}
}
steps {
script {
List<String> packagers = ['deb', 'rpm']
packagers.each { pkgr ->
sh "make NFPM_PACKAGER='${pkgr}' package"
}
List<String> attachments = sh(returnStdout: true, script: "find dist -type f -name '*.deb' -or -name '*.rpm' -or -name '*.ipk'").split(' ')
String releaseVersion = sh(returnStdout: true, script: "git describe --always | rev | cut -d '/' -f 1 | rev").trim()
String releaseBody = """
_Publication automatisée réalisée par Jenkins._ [Voir le job](${env.RUN_DISPLAY_URL})
"""
gitea.release('forge-jenkins', 'Cadoles', 'postgres-backup', [
'attachments': attachments,
'body': releaseBody,
'releaseName': "${releaseVersion}",
'releaseVersion': "${releaseVersion}"
])
}
}
}
}
post {
always {
cleanWs()
}
}
}

View File

@ -1,12 +0,0 @@
PACKAGE_VERSION ?= $(shell git describe --always | rev | cut -d '/' -f 1 | rev)
NFPM_PACKAGER ?= deb
package: dist
PACKAGE_VERSION=$(PACKAGE_VERSION) \
nfpm package \
--config nfpm.yml \
--target ./dist \
--packager $(NFPM_PACKAGER)
dist:
mkdir -p dist

View File

@ -4,17 +4,17 @@
# Optional system user to run backups as. If the user the script is running as doesn't match this # Optional system user to run backups as. If the user the script is running as doesn't match this
# the script terminates. Leave blank to skip check. # the script terminates. Leave blank to skip check.
BACKUP_USER=postgres BACKUP_USER=
# Optional hostname to adhere to pg_hba policies. Will default to "localhost" if none specified. # Optional hostname to adhere to pg_hba policies. Will default to "localhost" if none specified.
HOSTNAME=/var/run/postgresql HOSTNAME=
# Optional username to connect to database as. Will default to "postgres" if none specified. # Optional username to connect to database as. Will default to "postgres" if none specified.
USERNAME= USERNAME=
# This dir will be created if it doesn't exist. This must be writable by the user the script is # This dir will be created if it doesn't exist. This must be writable by the user the script is
# running as. # running as.
BACKUP_DIR=/var/backups/database/postgresql/ BACKUP_DIR=/home/backups/database/postgresql/
# List of strings to match against in database name, separated by space or comma, for which we only # List of strings to match against in database name, separated by space or comma, for which we only
# wish to keep a backup of the schema, not the data. Any database names which contain any of these # wish to keep a backup of the schema, not the data. Any database names which contain any of these

1
debian/compat vendored Normal file
View File

@ -0,0 +1 @@
9

14
debian/control vendored Normal file
View File

@ -0,0 +1,14 @@
Source: postgres-backup
Section: unknown
Priority: optional
Maintainer: Cadoles <contact@cadoles.com>
Build-Depends: debhelper (>= 8.0.0), dh-systemd (>= 1.5)
Standards-Version: 3.9.4
Homepage: http://forge.cadoles.com/Cadoles/postgres-backup
Vcs-Git: http://forge.cadoles.com/Cadoles/postgres-backup.git
Vcs-Browser: http://forge.cadoles.com/Cadoles/postgres-backup
Package: postgres-backup
Architecture: amd64
Depends: ${shlibs:Depends}, ${misc:Depends}
Description: PostgreSQL backup scripts

3
debian/postgres-backup.links vendored Normal file
View File

@ -0,0 +1,3 @@
/etc/postgres-backup/pg_backup.conf /usr/share/postgres-backup/pg_backup.conf
/usr/bin/pg_backup.sh /usr/share/postgres-backup/pg_backup.sh
/usr/bin/pg_backup_rotated.sh /usr/share/postgres-backup/pg_backup_rotated.sh

9
debian/postgres-backup.service vendored Normal file
View File

@ -0,0 +1,9 @@
[Unit]
Description=Run PostgreSQL backup
[Service]
Type=oneshot
ExecStart=/usr/bin/pg_backup_rotated.sh
[Install]
WantedBy=default.target

24
debian/rules vendored Normal file
View File

@ -0,0 +1,24 @@
#!/usr/bin/make -f
# -*- makefile -*-
# Uncomment this to turn on verbose mode.
export DH_VERBOSE=1
%:
dh $@ --with systemd
override_dh_auto_install:
mkdir -p debian/postgres-backup/usr/share/postgres-backup
mkdir -p debian/postgres-backup/etc/postgres-backup
mkdir -p debian/postgres-backup/usr/bin
cp script/pg_backup.sh debian/postgres-backup/usr/share/postgres-backup/pg_backup.sh
cp script/pg_backup_rotated.sh debian/postgres-backup/usr/share/postgres-backup/pg_backup_rotated.sh
cp conf/pg_backup.conf debian/postgres-backup/usr/share/postgres-backup/pg_backup.conf
chmod +x debian/postgres-backup/usr/share/postgres-backup/pg_backup_rotated.sh
chmod +x debian/postgres-backup/usr/share/postgres-backup/pg_backup.sh
install -D -m 644 debian/postgres-backup.timer debian/postgres-backup/lib/systemd/system/postgres-backup.timer
install -d debian/postgres-backup

1
debian/source/format vendored Normal file
View File

@ -0,0 +1 @@
3.0 (native)

View File

@ -1,9 +0,0 @@
FROM alpine:3.15
RUN apk add --no-cache make git curl jq bash openssl
RUN curl -k https://forge.cadoles.com/Cadoles/Jenkins/raw/branch/master/resources/com/cadoles/common/add-letsencrypt-ca.sh | bash
RUN wget https://github.com/goreleaser/nfpm/releases/download/v2.20.0/nfpm_2.20.0_Linux_x86_64.tar.gz \
&& tar -xzf nfpm_2.20.0_Linux_x86_64.tar.gz -C /usr/local/bin \
&& chmod +x /usr/local/bin/nfpm

View File

@ -1,10 +0,0 @@
[Unit]
Description=Run PostgreSQL backup
[Service]
Type=oneshot
ExecStart=/usr/bin/pg_backup_rotated.sh -c /etc/postgres-backup/pg_backup.conf
User=postgres
[Install]
WantedBy=default.target

View File

@ -1,39 +0,0 @@
name: "postgres-backup"
arch: "amd64"
platform: "linux"
version: "${PACKAGE_VERSION}"
section: "default"
priority: "extra"
maintainer: "Cadoles <contact@cadoles.com>"
description: |
PostgreSQL automated backup scripts
vendor: "Cadoles"
homepage: "https://forge.cadoles.com/Cadoles/postgres-backup"
license: "AGPL-3.0"
contents:
- src: script/pg_backup.sh
dst: /usr/share/postgres-backup/pg_backup.sh
file_info:
mode: 0755
- src: script/pg_backup_rotated.sh
dst: /usr/share/postgres-backup/pg_backup_rotated.sh
file_info:
mode: 0755
- src: /usr/share/postgres-backup/pg_backup.sh
dst: /usr/bin/pg_backup.sh
type: symlink
- src: /usr/share/postgres-backup/pg_backup_rotated.sh
dst: /usr/bin/pg_backup_rotated.sh
type: symlink
- src: conf/pg_backup.conf
dst: /etc/postgres-backup/pg_backup.conf
type: config|noreplace
- src: misc/packaging/postgres-backup.timer
dst: /usr/lib/systemd/system/postgres-backup.timer
- src: misc/packaging/postgres-backup.service
dst: /usr/lib/systemd/system/postgres-backup.service
- dst: /var/backups/database/postgresql
type: dir
file_info:
owner: postgres
group: postgres

View File

@ -24,7 +24,7 @@ done
if [ $# = 0 ]; then if [ $# = 0 ]; then
SCRIPTPATH=$(cd ${0%/*} && pwd -P) SCRIPTPATH=$(cd ${0%/*} && pwd -P)
source $SCRIPTPATH/pg_backup.conf source $SCRIPTPATH/pg_backup.config
fi; fi;
########################### ###########################