Skip to content
GitLab
Explorer
Connexion
Navigation principale
Rechercher ou aller à…
Projet
docker_odoo
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Analyse
Données d'analyse des chaînes de valeur
Analyse des contributeurs
Données d'analyse du dépôt
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté GitLab
Contribuer à GitLab
Donner votre avis
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
Le Filament
Ansible Roles
docker_odoo
Validations
60f76531
Valider
60f76531
rédigé
13 juin 2023
par
Théo - Le Filament
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
change: improve backups handling
parent
7401534b
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Modifications
4
Afficher les modifications d'espaces
En ligne
Côte à côte
Affichage de
4 fichiers modifiés
defaults/main.yml
+19
-46
19 ajouts, 46 suppressions
defaults/main.yml
tasks/instance.yml
+19
-20
19 ajouts, 20 suppressions
tasks/instance.yml
templates/backup.yaml.j2
+9
-9
9 ajouts, 9 suppressions
templates/backup.yaml.j2
templates/restore-odootest.yaml.j2
+9
-9
9 ajouts, 9 suppressions
templates/restore-odootest.yaml.j2
avec
56 ajouts
et
84 suppressions
defaults/main.yml
+
19
−
46
Voir le fichier @
60f76531
---
## Odoo configuration
## Odoo PostgreSQL version
odoo_db_version
:
'
13'
## Odoo version
odoo_version
:
'
16.0'
## Odoo websocket URI (websocket from 16.0 onwards, longpolling before)
websocket_uri
:
'
websocket'
odoo_setup_version
:
'
16'
odoo_setup_conf
:
16
:
odoo_version
:
'
16.0'
postgres_version
:
'
15'
websocket_uri
:
'
websocket'
15
:
odoo_version
:
'
15.0'
postgres_version
:
'
13'
websocket_uri
:
'
longpolling'
14
:
odoo_version
:
'
14.0'
postgres_version
:
'
13'
websocket_uri
:
'
longpolling'
12
:
odoo_version
:
'
12.0'
postgres_version
:
'
10'
websocket_uri
:
'
longpolling'
10
:
odoo_version
:
'
10.0'
postgres_version
:
'
9.6'
websocket_uri
:
'
longpolling'
odoo_setup_version
:
16
## Custom modules default URL for retrieving custom modules :
custom_modules_base_url
:
"
https://sources.le-filament.com/lefilament"
...
...
@@ -136,21 +107,23 @@ metabase: false
## OPTIONAL - For Backups only
# swift_accounts:
## Parameters for pushing backups to Object Storage - Instance 1
# swift_odoo_authurl: https://auth.cloud.ovh.net/v3/
# swift_odoo_authversion: 3
# swift_odoo_tenantid: "132e1fa"
# swift_odoo_tenantname: "12312534534"
# swift_odoo_username: "testuser"
# swift_odoo_password: "testpassword"
# swift_odoo_regionname: "GRA"
# - authurl: https://auth.cloud.ovh.net/v3/
# authversion: 3
# tenantid: "132e1fa"
# tenantname: "12312534534"
# username: "testuser"
# password: "testpassword"
# regionname: "GRA"
#
## Parameters for pushing backups to Object Storage - Instance 2
#
swift_odoo2_
authurl: https://auth.cloud.ovh.net/v3/
#
swift_odoo2_
authversion: 3
#
swift_odoo2_
tenantid: "12323534ab"
#
swift_odoo2_
tenantname: "123124235345"
#
swift_odoo2_
username: "testuser"
#
swift_odoo2_
password: "testpassword"
#
swift_odoo2_
regionname: "DE"
#
-
authurl: https://auth.cloud.ovh.net/v3/
#
authversion: 3
#
tenantid: "12323534ab"
#
tenantname: "123124235345"
#
username: "testuser"
#
password: "testpassword"
#
regionname: "DE"
## Passphrase for backups encryption
# odoo_backup_pass: notSecureEnoughPasswordToBeModified
Ce diff est replié.
Cliquez pour l'agrandir.
tasks/instance.yml
+
19
−
20
Voir le fichier @
60f76531
...
...
@@ -158,13 +158,14 @@
-
name
:
Copy compose file to restore db from backup_instance
template
:
src
:
restore-odootest.yaml.j2
dest
:
"
/home/docker/backups/restore-{{
item.key
}}{{
account
.key
}}.yaml"
dest
:
"
/home/docker/backups/restore-{{
item.key
}}{{
account
_index
+
1
}}.yaml"
owner
:
root
group
:
root
mode
:
'
0400'
with_dict
:
"
{{
swift_accounts
}}"
loop
:
"
{{
swift_accounts
}}"
loop_control
:
label
:
"
{{
account.key
}}"
label
:
"
account
{{
account_index
+
1
}}"
index_var
:
account_index
loop_var
:
account
# --------------------------------------------------
...
...
@@ -174,33 +175,31 @@
when
:
item.value.backup_instance | default(false) == item.key and item.value.backup_host | default(inventory_hostname) == inventory_hostname and inventory_hostname in groups.maintenance_contract
tags
:
'
backup_odoo'
block
:
-
name
:
Copy docker compose for backup
s
-
name
:
"
Copy
docker
compose
for
backup
account
{{
account_index
+
1
}}"
template
:
src
:
backup.yaml.j2
dest
:
"
/home/docker/backups/backup-{{
item.key
}}{{
account
.key
}}.yaml"
dest
:
"
/home/docker/backups/backup-{{
item.key
}}{{
account
_index
+
1
}}.yaml"
owner
:
root
group
:
root
mode
:
'
0400'
with_dict
:
"
{{
swift_accounts
}}"
loop
:
"
{{
swift_accounts
}}"
loop_control
:
label
:
"
{{
account.key
}}"
label
:
"
account
{{
account_index
+
1
}}"
index_var
:
account_index
loop_var
:
account
# TODO: duplicate with swift_accounts
-
name
:
Add cron job to run backup every day
-
name
:
"
Add
cron
job
to
run
backup
account
{{
account_index
+
1
}}
every
day
"
cron
:
name
:
"
backup
{{
item.key
}}"
minute
:
"
50"
hour
:
"
01"
job
:
/usr/local/bin/docker-compose -f /home/docker/backups/backup-{{ item.key }}1.yaml run --rm backup_odoo
-
name
:
Add cron job to run backup2 every day
cron
:
name
:
"
backup2
{{
item.key
}}"
minute
:
"
00"
hour
:
"
23"
job
:
/usr/local/bin/docker-compose -f /home/docker/backups/backup-{{ item.key }}2.yaml run --rm backup_odoo
name
:
"
backup
{{
item.key
}}{{
account_index
+
1
}}"
minute
:
"
{{
'%M'
|
strftime((('1970-01-01
'
+
backup_time_start)
|
to_datetime).timestamp()
+
(
swift_accounts
|
length
-
(account_index
+
1))
*
((backup_time_slot_duration
|
community.general.to_seconds
-
swift_accounts
|
length
*
backup_time_max_duration
|
community.general.to_seconds)
/
(swift_accounts
|
length
-
1)
+
backup_time_max_duration
|
community.general.to_seconds)
|
int)
}}"
hour
:
"
{{
'%H'
|
strftime((('1970-01-01
'
+
backup_time_start)
|
to_datetime).timestamp()
+
(
swift_accounts
|
length
-
(account_index
+
1))
*
((backup_time_slot_duration
|
community.general.to_seconds
-
swift_accounts
|
length
*
backup_time_max_duration
|
community.general.to_seconds)
/
(swift_accounts
|
length
-
1)
+
backup_time_max_duration
|
community.general.to_seconds)
|
int)
}}"
job
:
"
/usr/local/bin/docker-compose
-f
/home/docker/backups/backup-{{
item.key
}}{{
account_index
+
1
}}.yaml
run
--rm
backup_odoo"
loop
:
"
{{
swift_accounts
}}"
loop_control
:
label
:
"
account
{{
account_index
+
1
}}"
index_var
:
account_index
loop_var
:
account
# Flush handlers.
-
name
:
set facts
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
templates/backup.yaml.j2
+
9
−
9
Voir le fichier @
60f76531
...
...
@@ -9,19 +9,19 @@ services:
PGUSER: "{{ item.value.db_user }}"
PGPASSWORD: "{{ item.value.db_pass }}"
PASSPHRASE: "{{ item.value.odoo_backup_pass | default(item.value.master_pass) }}"
SWIFT_USERNAME: "{{ account.
value.swift_
username }}"
SWIFT_PASSWORD: "{{ account.
value.swift_
password }}"
SWIFT_AUTHURL: "{{ account.
value.swift_
authurl }}"
SWIFT_AUTHVERSION: {{ account.
value.swift_
authversion }}
SWIFT_TENANTNAME: "{{ account.
value.swift_
tenantname }}"
SWIFT_TENANTID: "{{ account.
value.swift_
tenantid }}"
SWIFT_REGIONNAME: "{{ account.
value.swift_
regionname }}"
SWIFT_USERNAME: "{{ account.username }}"
SWIFT_PASSWORD: "{{ account.password }}"
SWIFT_AUTHURL: "{{ account.authurl }}"
SWIFT_AUTHVERSION: {{ account.authversion }}
SWIFT_TENANTNAME: "{{ account.tenantname }}"
SWIFT_TENANTID: "{{ account.tenantid }}"
SWIFT_REGIONNAME: "{{ account.regionname }}"
JOB_200_WHEN: "never"
JOB_300_WHAT: "pg_dump --no-owner --format c --file $$SRC/$$PGDATABASE.pgdump && backup --full-if-older-than 6D"
JOB_302_WHAT: "dup remove-all-but-n-full 5 --force $$DST $$@"
JOB_302_WHEN: "daily"
volumes:
- {{ item.key }}{{ account
.key
}}_backup_cache:/root/.cache/duplicity/:z
- {{ item.key }}{{ account
_index + 1
}}_backup_cache:/root/.cache/duplicity/:z
- {{ item.key }}_filestore:/mnt/backup/src/odoo:z
{% if item.value.metabase | default(false) %}
- {{ item.key }}_metabase:/mnt/backup/src/metabase:z
...
...
@@ -40,7 +40,7 @@ networks:
encrypted: 1
volumes:
{{ item.key }}{{ account
.key
}}_backup_cache:
{{ item.key }}{{ account
_index + 1
}}_backup_cache:
{{ item.key }}_filestore:
external: true
{% if item.value.metabase | default(false) %}
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
templates/restore-odootest.yaml.j2
+
9
−
9
Voir le fichier @
60f76531
...
...
@@ -7,19 +7,19 @@ services:
- {{ item.key }}_default
- public
volumes:
- backups_{{ item.value.backup_instance }}{{ account
.key
}}_backup_cache:/root/.cache/duplicity/:z
- backups_{{ item.value.backup_instance }}{{ account
_index + 1
}}_backup_cache:/root/.cache/duplicity/:z
- {{ item.key }}_filestore:/mnt/backup/src/odoo:z
- ./post_restore-{{ item.key }}.sql:/tmp/post-restore.sql:ro
- ./pre_restore-{{ item.key }}.sql:/tmp/pre-restore.sql:ro
environment:
PGDATABASE: "{{ item.value.db }}"
SWIFT_USERNAME: "{{ account.
value.swift_
username }}"
SWIFT_PASSWORD: "{{ account.
value.swift_
password }}"
SWIFT_AUTHURL: "{{ account.
value.swift_
authurl }}"
SWIFT_AUTHVERSION: {{ account.
value.swift_
authversion }}
SWIFT_TENANTNAME: "{{ account.
value.swift_
tenantname }}"
SWIFT_TENANTID: "{{ account.
value.swift_
tenantid }}"
SWIFT_REGIONNAME: "{{ account.
value.swift_
regionname }}"
SWIFT_USERNAME: "{{ account.username }}"
SWIFT_PASSWORD: "{{ account.password }}"
SWIFT_AUTHURL: "{{ account.authurl }}"
SWIFT_AUTHVERSION: {{ account.authversion }}
SWIFT_TENANTNAME: "{{ account.tenantname }}"
SWIFT_TENANTID: "{{ account.tenantid }}"
SWIFT_REGIONNAME: "{{ account.regionname }}"
OPTIONS: "--force"
DST: "swift://{{ item.value.backup_instance }}_{{ item.value.backup_host | default(inventory_hostname) | lower }}"
PGUSER: "{{ odoo_instances[item.value.prod_instance | default(item.key )].db_user }}"
...
...
@@ -35,7 +35,7 @@ networks:
encrypted: 1
volumes:
backups_{{ item.value.backup_instance }}{{ account
.key
}}_backup_cache:
backups_{{ item.value.backup_instance }}{{ account
_index + 1
}}_backup_cache:
{% if item.value.backup_host | default(inventory_hostname) == inventory_hostname %}
external: true
{% endif %}
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
Aperçu
0%
Chargement en cours
Veuillez réessayer
ou
joindre un nouveau fichier
.
Annuler
You are about to add
0
people
to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Enregistrer le commentaire
Annuler
Veuillez vous
inscrire
ou vous
se connecter
pour commenter