Il y a 389 articles et 19 utilisateurs inscrits (ce bandeau est défini dans MediaWiki:Sitenotice)
« Script de Backup » : différence entre les versions
m →Crontab : 2>&1 journalisation des erreurs pendant les sauvegardes |
m a déplacé Doc/Script de Backup vers Script de Backup |
||
| (4 versions intermédiaires par le même utilisateur non affichées) | |||
| Ligne 2 : | Ligne 2 : | ||
== Arborescence == | == Arborescence == | ||
Le dossier {{path|./shell-scripts}} est un point de montage qui fait référence au dossier dans le {{path|{{var|$HOME}}/shell-scripts}} de l'utilisateur {{value|ajlsm}}. La procédure de mise en place du point de montage est décrite dans [[Fstab#Accès aux scripts AJLSM|Accès aux scripts AJLSM]]. | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
. | ./shell-scripts | ||
├── | ├── .ajlsm-projectsrc | ||
├── .ajlsmrc | |||
├── backup | |||
│ ├── backup.README | |||
│ ├── backup.sh | |||
│ ├── credentials-"$PROJET"-back.sh | |||
│ ├── credentials-"$PROJET"-front.sh | |||
│ └── path.sh | |||
├── .bashrc | |||
├── flushTomcatCache.sh | |||
├── httpd-maintenance | |||
│ ├── maintenance.html | |||
│ ├── maintenance.vhost.conf | |||
│ └── README | |||
├── installer.sh | |||
├── logs | ├── logs | ||
│ └── empty.log | |||
├── .projectrc | |||
├── projet-vhost.conf | |||
├── restartTomcat.sh | |||
├── toolbox.sh | |||
└── .zshrc | |||
</syntaxhighlight> | </syntaxhighlight> | ||
{{important|Ce script suppose une arborescence de fichiers tel que décrit dans [[Arborescence de production]]. Vous pouvez la réaliser via des liens symbolique}} | {{important|Ce script suppose une arborescence de fichiers tel que décrit dans [[Arborescence de production]]. Vous pouvez la réaliser via des liens symbolique}} | ||
| Ligne 22 : | Ligne 36 : | ||
== Adapter les variable aux projets == | == Adapter les variable aux projets == | ||
Le fichiers contenants les identifiants doivent être modifier pour indiquer : | Le fichiers contenants les identifiants doivent être modifier pour indiquer : | ||
* le nom de base postgreSQL | * le nom de base postgreSQL | ||
* nom d'utilisateur postgreSQL. | * nom d'utilisateur postgreSQL. | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
for i in ./shell-scripts/backup/*; do mv "$i" "${i/projet/$PROJECT}"; done | |||
</syntaxhighlight> | </syntaxhighlight> | ||
=== Crontab === | === Crontab === | ||
On termine par la modification du {{cmd|crontab}} pour que le script se déclenche régulièrement : | On termine par la modification du {{cmd|crontab}} pour que le script se déclenche régulièrement : | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
@daily /home/backupAgent/scripts/backup.sh ville-dole-front 2>&1 | tee -a "/home/backupAgent/logs/backup-$(date '+\%Y-\%b-\%d').log" | @daily bash /home/backupAgent/shell-scripts/backup/backup.sh ville-dole-front 2>&1 | tee -a "/home/backupAgent/logs/backup-$(date '+\%Y-\%b-\%d').log" | ||
#@daily /home/backupAgent/scripts/backup.sh ville-dole-back 2>&1 | tee -a "/home/backupAgent/logs/backup-$(date '+\%Y-\%b-\%d').log" | #@daily bash /home/backupAgent/shell-scripts/backup/backup.sh ville-dole-back 2>&1 | tee -a "/home/backupAgent/logs/backup-$(date '+\%Y-\%b-\%d').log" | ||
</syntaxhighlight> | </syntaxhighlight> | ||
[[category: | [[category:Bash]] | ||
[[category:Sauvegarde]] | [[category:Sauvegarde]] | ||
[[category:Doc]] | [[category:Doc]] | ||
Dernière version du 24 avril 2013 à 10:27
Nous utilisons un utilisateur special pour gérer les tâches de sauvegarde : backupAgent. Il a son propre compte UNIX, fait parti du groupe responsable de l'application et à son propre dossier personnel, dans lequel on place les sauvegardes (scénario par défaut).
Arborescence
[modifier | modifier le wikicode]Le dossier ./shell-scripts est un point de montage qui fait référence au dossier dans le $HOME/shell-scripts de l'utilisateur ajlsm. La procédure de mise en place du point de montage est décrite dans Accès aux scripts AJLSM.
./shell-scripts
├── .ajlsm-projectsrc
├── .ajlsmrc
├── backup
│ ├── backup.README
│ ├── backup.sh
│ ├── credentials-"$PROJET"-back.sh
│ ├── credentials-"$PROJET"-front.sh
│ └── path.sh
├── .bashrc
├── flushTomcatCache.sh
├── httpd-maintenance
│ ├── maintenance.html
│ ├── maintenance.vhost.conf
│ └── README
├── installer.sh
├── logs
│ └── empty.log
├── .projectrc
├── projet-vhost.conf
├── restartTomcat.sh
├── toolbox.sh
└── .zshrc
- backup.sh: script
- credentials-appli-recette.sh: identifiant pour l'application appli-recette
- credentials-appli-prod.sh: identifiant pour l'application appli-prod
- path.sh: chemin vers les ressources
Adapter les variable aux projets
[modifier | modifier le wikicode]Le fichiers contenants les identifiants doivent être modifier pour indiquer :
- le nom de base postgreSQL
- nom d'utilisateur postgreSQL.
for i in ./shell-scripts/backup/*; do mv "$i" "${i/projet/$PROJECT}"; done
Crontab
[modifier | modifier le wikicode]On termine par la modification du crontab pour que le script se déclenche régulièrement :
@daily bash /home/backupAgent/shell-scripts/backup/backup.sh ville-dole-front 2>&1 | tee -a "/home/backupAgent/logs/backup-$(date '+\%Y-\%b-\%d').log"
#@daily bash /home/backupAgent/shell-scripts/backup/backup.sh ville-dole-back 2>&1 | tee -a "/home/backupAgent/logs/backup-$(date '+\%Y-\%b-\%d').log"