Evolution script sauvegarde-2

Demande d'aide : c'est ici.
Avatar de l’utilisateur
DbFr871
Membre très actif
Membre très actif
Messages : 1140
Inscription : 17 mai 2016, 20:48
Localisation : Nègrepelissien
Contact :
Status : Hors-ligne

:006:
Je viens de le tester et il y a des erreurs...
j'y mets les doigts dedans... :icon_e_surprised: :icon_biggrin:
MicP a écrit : 05 oct. 2017, 11:41 Fais un essai avec le script ci-dessous :

Code : Tout sélectionner

#!/bin/bash

backup="/home/bernard/bin/Sauvegardes/backuperror0Del-portable_Sauv1T_500go_SSD224Go.log"

### Couleurs :
INVRT="\\033[7m"
STNDT="\\033[0;39m"
ROUGE="\\033[1;31m"
BLANC="\\033[0;02m"
JAUNE="\\033[1;33m"
BLEU="\\033[1;34m"
VERT="\\033[1;32m"
ROSE="\\033[1;35m"
CYAN="\\033[1;36m"

### Tableaux :
tblNomSauv=( "SSD224Go"                                              "DD1To"                      "DD500Go"           )
tblColoMsg=( "${CYAN}"                                               "${ROSE}"                    "${BLEU}"           )
tblMntPnts=( "/media/bernard/SSD224Go/"                              "/media/bernard/Sauv1To-a/"  "/media/usb0/"      )
tblTrgDirs=( ""                                                      "SauvDdPrincipal1/"          "SauvDdPrincipal2/" )
tblSrcRoot=( "/home/bernard/"                                        "/"                          "/"                 )
tblSrcDirs=( "MesPhotos/;MesDocuments/;DocumentsPerso/;MesScripts/"  "home/;etc/"                 "home/;etc/"        )

#=======
### Recommencer les tests si la touche R a été préssée 
REPLY="r"
while [[ $REPLY = [rR] ]]; do
    msg="\n"
    erreurs=0
    for idx in ${!tblMntPnts[@]}; do
        msg+="${tblColoMsg[${idx}]}Le point de mountage\t${STNDT}${tblMntPnts[${idx}]} ${INVRT}"
        if mountpoint -q "${tblMntPnts[${idx}]}"; then
            msg+="${VERT}est bien un point de mountage accessible."
        else
            erreurs=1
            msg+="${ROUGE}n'est pas un point de mountage."
        fi
        msg+="${STNDT}\n"

        msg+="${tblColoMsg[${idx}]}Le répertoire\t\t${STNDT}${tblMntPnts[${idx}]}${tblTrgDirs[${idx}]} ${INVRT}"
        if test -w "${tblMntPnts[${idx}]}${tblTrgDirs[${idx}]}"; then
            msg+="${VERT}est OK."
        else
            erreurs=1
            msg+="${ROUGE}n'est pas accessible en écriture."
        fi
        msg+="${STNDT}\n\n"
    done
    echo -e "${msg}"
    ### Si erreur trouvée => Dialogue
    if test $erreurs = 1; then
        echo -e "${INVRT}${VERT}P${STNDT}oursuivre la Sauvegarde, ${INVRT}${VERT}Q${STNDT}uitter (ou autre touche), ${INVRT}${VERT}R${STNDT}ecommencer.\n"
        read -sn1
        [[ $REPLY = [qQ] ]] && { echo -e "${ROUGE}Abandon sauvegarde.${STNDT}\nSortie Sauvegarde\n"; exit; }
    else
       REPLY="P"
    fi
done

### Fonction pour options et arguments de rsync
optsArgsForRsync() {
    printf %s "--archive --partial --delete-during "
    IFS=";"
    for myDir in ${tblSrcDirs[${1}]}; do
        printf %s "--include=\"${myDir}***\" "
    done
    printf %s "--exclude=\"*\" ${tblSrcRoot[${1}]} ${tblMntPnts[${1}]}${tblTrgDirs[${1}]}"
}

### Sauvegardes
for idx in ${!tblNomSauv[@]}; do
    echo -e "${tblColoMsg[${idx}]}=========================================\nSynchronisation en cours pour ${tblNomSauv[${idx}]}..."
    rsync $(optsArgsForRsync ${idx})  2>> "${backup}"
done

# ⦅⦿⦿⦆ ⦅⦿⦿⦆ ⦅⦿⦿⦆
maDate="$(date +'le : '%d-%m-%Y' à '%T)"
if [ -s "${backup}" ]; then
    echo -e $STNDT "============================================"
    echo -e $STNDT "Sauvegarde terminée  ${maDate}\n"
else
    echo -e $STNDT "Procédure interrompue par l'utilisateur ${maDate}"
fi
read -p "Pour fermer le programme de sauvegarde : Ctrl + C"
# ---- fin du script ----
.

Pour info, voici le résultat du fichier backup :
rsync error: received SIGINT, SIGTERM, or SIGHUP (code 20) at rsync.c(638) [sender=3.1.2]
rsync error: received SIGINT, SIGTERM, or SIGHUP (code 20) at rsync.c(638) [sender=3.1.2]
rsync error: received SIGINT, SIGTERM, or SIGHUP (code 20) at io.c(513) [generator=3.1.2]
rsync error: received SIGINT, SIGTERM, or SIGHUP (code 20) at rsync.c(638) [sender=3.1.2]
rsync error: received SIGINT, SIGTERM, or SIGHUP (code 20) at io.c(513) [generator=3.1.2]
rsync error: received SIGINT, SIGTERM, or SIGHUP (code 20) at rsync.c(638) [sender=3.1.2]


j'en ai trouvé une sur les dossiers à sauvegarder, je regarde pour le retour de backup...
Cordialement,
Bernard
Debian9.1Stretch-XFCE-64bits-Sony-Vaio,Intel-P8400-2.26GHz,DD-SeagateSSHD500Go,GeForce9300M-GS-256Mo
MicP
Modérateur
Modérateur
Messages : 896
Inscription : 16 avr. 2016, 22:14
Status : Hors-ligne

Ces 6 lignes d'erreus doivent correspondre aux essais précédents
pendant lesquels tu avais interrompu le programme rsync avec Ctrl+c
comme on le voit dans la capture d'écran de ton message #37

Entre chaque lancement du script, tu n'avais sans doute pas effacé le contenu ou supprimé le fichier d'erreurs.
Avatar de l’utilisateur
DbFr871
Membre très actif
Membre très actif
Messages : 1140
Inscription : 17 mai 2016, 20:48
Localisation : Nègrepelissien
Contact :
Status : Hors-ligne

:006:
MicP a écrit : 06 oct. 2017, 01:18 Ces 6 lignes d'erreus doivent correspondre aux essais précédents
pendant lesquels tu avais interrompu le programme rsync avec Ctrl+c
comme on le voit dans la capture d'écran de ton message #37

Entre chaque lancement du script, tu n'avais sans doute pas effacé le contenu ou supprimé le fichier d'erreurs.
.
Ce qui signifie que le fichier backup ne recense pas les dates et heures des sauvegardes ?
comme le faisait les précédents scripts ?

je vais faire un fichier à "lui", pour éviter de mélanger les backup des différents scripts :wink:
Cordialement,
Bernard
Debian9.1Stretch-XFCE-64bits-Sony-Vaio,Intel-P8400-2.26GHz,DD-SeagateSSHD500Go,GeForce9300M-GS-256Mo
MicP
Modérateur
Modérateur
Messages : 896
Inscription : 16 avr. 2016, 22:14
Status : Hors-ligne

Dans ton script original, tu avais utilisé une redirection du flux N°2 (stderr) vers un fichier dont le nom de variable est backup.

Si la sauvegarde s'est bien déroulé, il n'y aura rien dans ce flux,
d'autant qu'à la fin de ton script, tu teste si backup existe et a une taille non nulle
pour afficher un message disant : "Sauvegarde terminée ${maDate}"

Je n'ai pas très bien compris ce que tu comptais faire en faisant ça,
alors j'ai laissé tout ça comme c'était.

Il existe l'option de rsync --log-file qui permet de créer un fichier log
Avatar de l’utilisateur
DbFr871
Membre très actif
Membre très actif
Messages : 1140
Inscription : 17 mai 2016, 20:48
Localisation : Nègrepelissien
Contact :
Status : Hors-ligne

:006:
MicP a écrit : 06 oct. 2017, 13:09 Dans ton script original, tu avais utilisé une redirection du flux N°2 (stderr) vers un fichier dont le nom de variable est backup.

Si la sauvegarde s'est bien déroulé, il n'y aura rien dans ce flux,
d'autant qu'à la fin de ton script, tu teste si backup existe et a une taille non nulle
pour afficher un message disant : "Sauvegarde terminée ${maDate}"

Je n'ai pas très bien compris ce que tu comptais faire en faisant ça,
alors j'ai laissé tout ça comme c'était.

Il existe l'option de rsync --log-file qui permet de créer un fichier log
.
Ce que je compte, est de vérifier que tout c'est bien déroulé à "chaque fois" que je sauvegarde, tout simplement :wink:

je sais, c'est toto matik, mais comme toute confiance n'exclut pas la vérification...

ce qui, en bon français positif (ce que je suis :icon_biggrin: ) devient : la confiance inclut la vérification ! :icon_biggrin:
Cordialement,
Bernard
Debian9.1Stretch-XFCE-64bits-Sony-Vaio,Intel-P8400-2.26GHz,DD-SeagateSSHD500Go,GeForce9300M-GS-256Mo
MicP
Modérateur
Modérateur
Messages : 896
Inscription : 16 avr. 2016, 22:14
Status : Hors-ligne

vérifier que tout c'est bien déroulé à "chaque fois" que je sauvegarde, tout simplement

C'est peut être simple, mais très vague comme description de ce que tu voudrais.

Il te faudrait voir le paragraphe log format de la page man de rsyncd.conf
qui liste toutes les possibilités de format des informations à transmettre au fichier log

Sinon, par défaut, le format des informations transmises au fichier log donnent :

Code : Tout sélectionner

2017/10/06 14:48:37 [4132] building file list
2017/10/06 14:48:37 [4132] sent 9534 bytes  received 79 bytes  total size 430615856
2017/10/06 14:48:37 [4136] building file list
2017/10/06 14:48:37 [4136] sent 9534 bytes  received 79 bytes  total size 430615856
Avatar de l’utilisateur
DbFr871
Membre très actif
Membre très actif
Messages : 1140
Inscription : 17 mai 2016, 20:48
Localisation : Nègrepelissien
Contact :
Status : Hors-ligne

MicP a écrit : 06 oct. 2017, 15:01 vérifier que tout c'est bien déroulé à "chaque fois" que je sauvegarde, tout simplement

C'est peut être simple, mais très vague comme description de ce que tu voudrais.

Il te faudrait voir le paragraphe log format de la page man de rsyncd.conf
qui liste toutes les possibilités de format des informations à transmettre au fichier log

Sinon, par défaut, le format des informations transmises au fichier log donnent :

Code : Tout sélectionner

2017/10/06 14:48:37 [4132] building file list
2017/10/06 14:48:37 [4132] sent 9534 bytes  received 79 bytes  total size 430615856
2017/10/06 14:48:37 [4136] building file list
2017/10/06 14:48:37 [4136] sent 9534 bytes  received 79 bytes  total size 430615856
.

Voici ce que le backup dit :

Code : Tout sélectionner

mercredi 13 septembre 2017, 13:02:00 (UTC+0200)
mercredi 13 septembre 2017, 13:06:06 (UTC+0200)
mercredi 13 septembre 2017, 16:09:50 (UTC+0200)
.
Simple, non ?

s'il y a un souci, il indiquait ce qui "clochait"... et, que je n'ai pas gardé... :icon_biggrin:

possible de faire identique ?
Cordialement,
Bernard
Debian9.1Stretch-XFCE-64bits-Sony-Vaio,Intel-P8400-2.26GHz,DD-SeagateSSHD500Go,GeForce9300M-GS-256Mo
MicP
Modérateur
Modérateur
Messages : 896
Inscription : 16 avr. 2016, 22:14
Status : Hors-ligne

Code : Tout sélectionner

#!/bin/bash

backup="/home/bernard/bin/Sauvegardes/backuperror0Del-portable_Sauv1T_500go_SSD224Go.log"

### Couleurs :
INVRT="\\033[7m"
STNDT="\\033[0;39m"
ROUGE="\\033[1;31m"
BLANC="\\033[0;02m"
JAUNE="\\033[1;33m"
BLEU="\\033[1;34m"
VERT="\\033[1;32m"
ROSE="\\033[1;35m"
CYAN="\\033[1;36m"

### Tableaux :
tblNomSauv=( "SSD224Go"                                              "DD1To"                      "DD500Go"           )--archive --partial --delete-during
tblColoMsg=( "${CYAN}"                                               "${ROSE}"                    "${BLEU}"           )
tblMntPnts=( "/media/bernard/SSD224Go/"                              "/media/bernard/Sauv1To-a/"  "/media/usb0/"      )
tblTrgDirs=( ""                                                      "SauvDdPrincipal1/"          "SauvDdPrincipal2/" )
tblSrcRoot=( "/home/bernard/"                                        "/"                          "/"                 )
tblSrcDirs=( "MesPhotos/;MesDocuments/;DocumentsPerso/;MesScripts/"  "home/;etc/"                 "home/;etc/"        )

### Options rsync
optsRsync="--archive --partial --delete-during"

#=======
### Recommencer les tests si la touche R a été préssée 
REPLY="r"
while [[ $REPLY = [rR] ]]; do
    msg="\n"
    erreurs=0
    for idx in ${!tblMntPnts[@]}; do
        msg+="${tblColoMsg[${idx}]}Le point de mountage\t${STNDT}${tblMntPnts[${idx}]} ${INVRT}"
        if mountpoint -q "${tblMntPnts[${idx}]}"; then
            msg+="${VERT}est bien un point de mountage accessible."
        else
            erreurs=1
            msg+="${ROUGE}n'est pas un point de mountage."
        fi
        msg+="${STNDT}\n"

        msg+="${tblColoMsg[${idx}]}Le répertoire\t\t${STNDT}${tblMntPnts[${idx}]}${tblTrgDirs[${idx}]} ${INVRT}"
        if test -w "${tblMntPnts[${idx}]}${tblTrgDirs[${idx}]}"; then
            msg+="${VERT}est OK."
        else
            erreurs=1
            msg+="${ROUGE}n'est pas accessible en écriture."
        fi
        msg+="${STNDT}\n\n"
    done
    echo -e "${msg}"
    ### Si erreur trouvée => Dialogue
    if test $erreurs = 1; then
        echo -e "${INVRT}${VERT}P${STNDT}oursuivre la Sauvegarde, ${INVRT}${VERT}Q${STNDT}uitter (ou autre touche), ${INVRT}${VERT}R${STNDT}ecommencer.\n"
        read -sn1
        [[ $REPLY = [qQ] ]] && { echo -e "${ROUGE}Abandon sauvegarde.${STNDT}\nSortie Sauvegarde\n"; exit; }
    else
       REPLY="P"
    fi
done

### Fonction pour options et arguments de rsync
optsArgsForRsync() {
    printf %s "${optsRsync} "--archive --partial --delete-during
    IFS=";"
    for myDir in ${tblSrcDirs[${1}]}; do
        printf %s "--include=\"${myDir}***\" "
    done
    printf %s "--exclude=\"*\" ${tblSrcRoot[${1}]} ${tblMntPnts[${1}]}${tblTrgDirs[${1}]}"
}

### Sauvegardes
for idx in ${!tblNomSauv[@]}; do
    echo -e "${tblColoMsg[${idx}]}=========================================\nSynchronisation en cours pour ${tblNomSauv[${idx}]}..."
    rsync $(optsArgsForRsync ${idx})  2>> "${backup}"
done

### Messages de fin
maDate="$(date +'le : '%d-%m-%Y' à '%T)"
echo -e "${STNDT}============================================\nSauvegarde terminée ${maDate}"
echo "${maDate}" >> "${backup}"
Avatar de l’utilisateur
DbFr871
Membre très actif
Membre très actif
Messages : 1140
Inscription : 17 mai 2016, 20:48
Localisation : Nègrepelissien
Contact :
Status : Hors-ligne

Ah là... il y en a pour ses pépettes... :icon_biggrin:

Je vois que je t'ai agacé... si, si... 4 scripts dans le même script... :icon_e_surprised: :rofl: :wink:
Cordialement,
Bernard
Debian9.1Stretch-XFCE-64bits-Sony-Vaio,Intel-P8400-2.26GHz,DD-SeagateSSHD500Go,GeForce9300M-GS-256Mo
MicP
Modérateur
Modérateur
Messages : 896
Inscription : 16 avr. 2016, 22:14
Status : Hors-ligne

Non, c'est moi qui me suis mélangé les pinceaux en faisant le copié/collé. :icon_e_biggrin:
Je viens de le corriger
Avatar de l’utilisateur
DbFr871
Membre très actif
Membre très actif
Messages : 1140
Inscription : 17 mai 2016, 20:48
Localisation : Nègrepelissien
Contact :
Status : Hors-ligne

MicP a écrit : 06 oct. 2017, 18:17 Non, c'est moi qui me suis mélangé les pinceaux en faisant le copié/collé. :icon_e_biggrin:
Je viens de le corriger
.
j'ai vu, rassures Toi :wink:
Cordialement,
Bernard
Debian9.1Stretch-XFCE-64bits-Sony-Vaio,Intel-P8400-2.26GHz,DD-SeagateSSHD500Go,GeForce9300M-GS-256Mo
Avatar de l’utilisateur
DbFr871
Membre très actif
Membre très actif
Messages : 1140
Inscription : 17 mai 2016, 20:48
Localisation : Nègrepelissien
Contact :
Status : Hors-ligne

j'avais commencé à tester mais :

Code : Tout sélectionner

bernard-portable:/home/bernard# /home/bernard/MesScripts/Sauvegarde_portable_Sauv1T_500go_SSD224Go_5-partiel

Le point de mountage	/media/bernard/SSD224Go/  est bien un point de mountage accessible.
Le répertoire		/media/bernard/SSD224Go/  est OK.


/home/bernard/MesScripts/Sauvegarde_portable_Sauv1T_500go_SSD224Go_5-partiel: ligne 75: erreur de syntaxe : fin de fichier prématurée
bernard-portable:/home/bernard# 
.
il manquait une } de fin...


et avec celui que tu viens de "terminer", voici ce qu'il dit, dans le fichier backup, parce que j'ai été obligé de l'arrêter, sinon, il copiait tout le " / "...

Code : Tout sélectionner

rsync error: received SIGINT, SIGTERM, or SIGHUP (code 20) at rsync.c(638) [sender=3.1.2]
le : 06-10-2017 à 18:49:08
.

et en fenêtre ça donne :

Code : Tout sélectionner

bernard-portable:/home/bernard# /home/bernard/MesScripts/Sauvegarde_portable_Sauv1T_500go_SSD224Go_6-partiel

Le point de mountage	/media/bernard/SSD224Go/  est bien un point de mountage accessible.
Le répertoire		/media/bernard/SSD224Go/  est OK.


=========================================
Synchronisation en cours pour SSD224Go...
sending incremental file list
./
.ICEauthority
         92,430 100%   56.90MB/s    0:00:00 (xfr#1, ir-chk=9797/9799)
.Xauthority
             61 100%   59.57kB/s    0:00:00 (xfr#2, ir-chk=9796/9799)
.Xmodmap
             23 100%   22.46kB/s    0:00:00 (xfr#3, ir-chk=9795/9799)
.bash_history
          3,652 100%    3.48MB/s    0:00:00 (xfr#4, ir-chk=9794/9799)
.bash_logout
            220 100%  214.84kB/s    0:00:00 (xfr#5, ir-chk=9793/9799)
.bashrc
          3,515 100%    3.35MB/s    0:00:00 (xfr#6, ir-chk=9792/9799)
.dmrc
             55 100%   53.71kB/s    0:00:00 (xfr#7, ir-chk=9791/9799)
.gksu.lock
              0 100%    0.00kB/s    0:00:00 (xfr#8, ir-chk=9790/9799)
.hugin
          3,091 100%    1.47MB/s    0:00:00 (xfr#9, ir-chk=9789/9799)
.install4j
             82 100%   40.04kB/s    0:00:00 (xfr#10, ir-chk=9788/9799)
.mtoolsrc
             20 100%    1.40kB/s    0:00:00 (xfr#11, ir-chk=9787/9799)
.multisystem-theme
              6 100%    0.37kB/s    0:00:00 (xfr#12, ir-chk=9786/9799)
.odbc.ini
              0 100%    0.00kB/s    0:00:00 (xfr#13, ir-chk=9785/9799)
.profile
            720 100%   43.95kB/s    0:00:00 (xfr#14, ir-chk=9784/9799)
.ptbt1
              2 100%    0.08kB/s    0:00:00 (xfr#15, ir-chk=9783/9799)
.recently-used
... 
.
ce doit être la commande exclude qui fait le pâté...


pour "tester", je supprime dans le fichier que tu fais, les 2 autres supports, pour voir si déjà avec 1, ça fonctionne !

en souhaitant que cela ne soit pas ce que j'ai fait, qui fasse le "pâté"... :icon_e_surprised:
Cordialement,
Bernard
Debian9.1Stretch-XFCE-64bits-Sony-Vaio,Intel-P8400-2.26GHz,DD-SeagateSSHD500Go,GeForce9300M-GS-256Mo
Avatar de l’utilisateur
DbFr871
Membre très actif
Membre très actif
Messages : 1140
Inscription : 17 mai 2016, 20:48
Localisation : Nègrepelissien
Contact :
Status : Hors-ligne

et dans les options, je mets

Code : Tout sélectionner

### Options rsync
optsRsync="--archive --partial --progress --delete-during --stats"
.
pour "voir" ce qui se passe... c'est ma partie "curieux" qui le veut... :icon_biggrin:
Cordialement,
Bernard
Debian9.1Stretch-XFCE-64bits-Sony-Vaio,Intel-P8400-2.26GHz,DD-SeagateSSHD500Go,GeForce9300M-GS-256Mo
Avatar de l’utilisateur
DbFr871
Membre très actif
Membre très actif
Messages : 1140
Inscription : 17 mai 2016, 20:48
Localisation : Nègrepelissien
Contact :
Status : Hors-ligne

voici le fichier backup

Code : Tout sélectionner

rsync error: received SIGINT, SIGTERM, or SIGHUP (code 20) at rsync.c(638) [sender=3.1.2]
le : 06-10-2017 à 18:49:08
rsync  version 3.1.2  protocol version 31
Copyright (C) 1996-2015 by Andrew Tridgell, Wayne Davison, and others.
Web site: http://rsync.samba.org/
Capabilities:
    64-bit files, 64-bit inums, 64-bit timestamps, 64-bit long ints,
    socketpairs, hardlinks, symlinks, IPv6, batchfiles, inplace,
    append, ACLs, xattrs, iconv, symtimes, prealloc

rsync comes with ABSOLUTELY NO WARRANTY.  This is free software, and you
are welcome to redistribute it under certain conditions.  See the GNU
General Public Licence for details.

rsync is a file transfer program capable of efficient remote update
via a fast differencing algorithm.

Usage: rsync [OPTION]... SRC [SRC]... DEST
  or   rsync [OPTION]... SRC [SRC]... [USER@]HOST:DEST
  or   rsync [OPTION]... SRC [SRC]... [USER@]HOST::DEST
  or   rsync [OPTION]... SRC [SRC]... rsync://[USER@]HOST[:PORT]/DEST
  or   rsync [OPTION]... [USER@]HOST:SRC [DEST]
  or   rsync [OPTION]... [USER@]HOST::SRC [DEST]
  or   rsync [OPTION]... rsync://[USER@]HOST[:PORT]/SRC [DEST]
The ':' usages connect via remote shell, while '::' & 'rsync://' usages connect
to an rsync daemon, and require SRC or DEST to start with a module name.

Options
 -v, --verbose               increase verbosity
     --info=FLAGS            fine-grained informational verbosity
     --debug=FLAGS           fine-grained debug verbosity
     --msgs2stderr           special output handling for debugging
 -q, --quiet                 suppress non-error messages
     --no-motd               suppress daemon-mode MOTD (see manpage caveat)
 -c, --checksum              skip based on checksum, not mod-time & size
 -a, --archive               archive mode; equals -rlptgoD (no -H,-A,-X)
     --no-OPTION             turn off an implied OPTION (e.g. --no-D)
 -r, --recursive             recurse into directories
 -R, --relative              use relative path names
     --no-implied-dirs       don't send implied dirs with --relative
 -b, --backup                make backups (see --suffix & --backup-dir)
     --backup-dir=DIR        make backups into hierarchy based in DIR
     --suffix=SUFFIX         set backup suffix (default ~ w/o --backup-dir)
 -u, --update                skip files that are newer on the receiver
     --inplace               update destination files in-place (SEE MAN PAGE)
     --append                append data onto shorter files
     --append-verify         like --append, but with old data in file checksum
 -d, --dirs                  transfer directories without recursing
 -l, --links                 copy symlinks as symlinks
 -L, --copy-links            transform symlink into referent file/dir
     --copy-unsafe-links     only "unsafe" symlinks are transformed
     --safe-links            ignore symlinks that point outside the source tree
     --munge-links           munge symlinks to make them safer (but unusable)
 -k, --copy-dirlinks         transform symlink to a dir into referent dir
 -K, --keep-dirlinks         treat symlinked dir on receiver as dir
 -H, --hard-links            preserve hard links
 -p, --perms                 preserve permissions
 -E, --executability         preserve the file's executability
     --chmod=CHMOD           affect file and/or directory permissions
 -A, --acls                  preserve ACLs (implies --perms)
 -X, --xattrs                preserve extended attributes
 -o, --owner                 preserve owner (super-user only)
 -g, --group                 preserve group
     --devices               preserve device files (super-user only)
     --copy-devices          copy device contents as regular file
     --specials              preserve special files
 -D                          same as --devices --specials
 -t, --times                 preserve modification times
 -O, --omit-dir-times        omit directories from --times
 -J, --omit-link-times       omit symlinks from --times
     --super                 receiver attempts super-user activities
     --fake-super            store/recover privileged attrs using xattrs
 -S, --sparse                handle sparse files efficiently
     --preallocate           allocate dest files before writing them
 -n, --dry-run               perform a trial run with no changes made
 -W, --whole-file            copy files whole (without delta-xfer algorithm)
 -x, --one-file-system       don't cross filesystem boundaries
 -B, --block-size=SIZE       force a fixed checksum block-size
 -e, --rsh=COMMAND           specify the remote shell to use
     --rsync-path=PROGRAM    specify the rsync to run on the remote machine
     --existing              skip creating new files on receiver
     --ignore-existing       skip updating files that already exist on receiver
     --remove-source-files   sender removes synchronized files (non-dirs)
     --del                   an alias for --delete-during
     --delete                delete extraneous files from destination dirs
     --delete-before         receiver deletes before transfer, not during
     --delete-during         receiver deletes during the transfer
     --delete-delay          find deletions during, delete after
     --delete-after          receiver deletes after transfer, not during
     --delete-excluded       also delete excluded files from destination dirs
     --ignore-missing-args   ignore missing source args without error
     --delete-missing-args   delete missing source args from destination
     --ignore-errors         delete even if there are I/O errors
     --force                 force deletion of directories even if not empty
     --max-delete=NUM        don't delete more than NUM files
     --max-size=SIZE         don't transfer any file larger than SIZE
     --min-size=SIZE         don't transfer any file smaller than SIZE
     --partial               keep partially transferred files
     --partial-dir=DIR       put a partially transferred file into DIR
     --delay-updates         put all updated files into place at transfer's end
 -m, --prune-empty-dirs      prune empty directory chains from the file-list
     --numeric-ids           don't map uid/gid values by user/group name
     --usermap=STRING        custom username mapping
     --groupmap=STRING       custom groupname mapping
     --chown=USER:GROUP      simple username/groupname mapping
     --timeout=SECONDS       set I/O timeout in seconds
     --contimeout=SECONDS    set daemon connection timeout in seconds
 -I, --ignore-times          don't skip files that match in size and mod-time
 -M, --remote-option=OPTION  send OPTION to the remote side only
     --size-only             skip files that match in size
     --modify-window=NUM     compare mod-times with reduced accuracy
 -T, --temp-dir=DIR          create temporary files in directory DIR
 -y, --fuzzy                 find similar file for basis if no dest file
     --compare-dest=DIR      also compare destination files relative to DIR
     --copy-dest=DIR         ... and include copies of unchanged files
     --link-dest=DIR         hardlink to files in DIR when unchanged
 -z, --compress              compress file data during the transfer
     --compress-level=NUM    explicitly set compression level
     --skip-compress=LIST    skip compressing files with a suffix in LIST
 -C, --cvs-exclude           auto-ignore files the same way CVS does
 -f, --filter=RULE           add a file-filtering RULE
 -F                          same as --filter='dir-merge /.rsync-filter'
                             repeated: --filter='- .rsync-filter'
     --exclude=PATTERN       exclude files matching PATTERN
     --exclude-from=FILE     read exclude patterns from FILE
     --include=PATTERN       don't exclude files matching PATTERN
     --include-from=FILE     read include patterns from FILE
     --files-from=FILE       read list of source-file names from FILE
 -0, --from0                 all *-from/filter files are delimited by 0s
 -s, --protect-args          no space-splitting; only wildcard special-chars
     --address=ADDRESS       bind address for outgoing socket to daemon
     --port=PORT             specify double-colon alternate port number
     --sockopts=OPTIONS      specify custom TCP options
     --blocking-io           use blocking I/O for the remote shell
     --stats                 give some file-transfer stats
 -8, --8-bit-output          leave high-bit chars unescaped in output
 -h, --human-readable        output numbers in a human-readable format
     --progress              show progress during transfer
 -P                          same as --partial --progress
 -i, --itemize-changes       output a change-summary for all updates
     --out-format=FORMAT     output updates using the specified FORMAT
     --log-file=FILE         log what we're doing to the specified FILE
     --log-file-format=FMT   log updates using the specified FMT
     --password-file=FILE    read daemon-access password from FILE
     --list-only             list the files instead of copying them
     --bwlimit=RATE          limit socket I/O bandwidth
     --stop-at=y-m-dTh:m     Stop rsync at year-month-dayThour:minute
     --time-limit=MINS       Stop rsync after MINS minutes have elapsed
     --outbuf=N|L|B          set output buffering to None, Line, or Block
     --write-batch=FILE      write a batched update to FILE
     --only-write-batch=FILE like --write-batch but w/o updating destination
     --read-batch=FILE       read a batched update from FILE
     --protocol=NUM          force an older protocol version to be used
     --iconv=CONVERT_SPEC    request charset conversion of filenames
     --checksum-seed=NUM     set block/file checksum seed (advanced)
     --noatime               do not alter atime when opening source files
 -4, --ipv4                  prefer IPv4
 -6, --ipv6                  prefer IPv6
     --version               print version number
(-h) --help                  show this help (-h is --help only if used alone)

Use "rsync --daemon --help" to see the daemon-mode command-line options.
Please see the rsync(1) and rsyncd.conf(5) man pages for full documentation.
See http://rsync.samba.org/ for updates, bug reports, and answers
rsync error: syntax or usage error (code 1) at main.c(1653) [Receiver=3.1.2]
le : 06-10-2017 à 19:06:31
rsync error: received SIGINT, SIGTERM, or SIGHUP (code 20) at rsync.c(638) [sender=3.1.2]
le : 06-10-2017 à 19:07:23
Cordialement,
Bernard
Debian9.1Stretch-XFCE-64bits-Sony-Vaio,Intel-P8400-2.26GHz,DD-SeagateSSHD500Go,GeForce9300M-GS-256Mo
Avatar de l’utilisateur
DbFr871
Membre très actif
Membre très actif
Messages : 1140
Inscription : 17 mai 2016, 20:48
Localisation : Nègrepelissien
Contact :
Status : Hors-ligne

après test, voici le script comme je l'ai modifié :

Code : Tout sélectionner

#!/bin/bash

backup="/home/bernard/bin/Sauvegardes/backuperror0Del-portable_Sauv1T_500go_SSD224Go_6-partiel1.log"

### Couleurs :
INVRT="\\033[7m"
STNDT="\\033[0;39m"
ROUGE="\\033[1;31m"
BLANC="\\033[0;02m"
JAUNE="\\033[1;33m"
BLEU="\\033[1;34m"
VERT="\\033[1;32m"
ROSE="\\033[1;35m"
CYAN="\\033[1;36m"

### Tableaux :
tblNomSauv=( "SSD224Go")
tblColoMsg=( "${CYAN}")
tblMntPnts=( "/media/bernard/SSD224Go/")
tblTrgDirs=( "")
tblSrcRoot=( "/home/bernard/")
tblSrcDirs=( "MesPhotos/;MesDocuments/;DocumentsPerso/;MesScripts/")

### Options rsync
optsRsync="--archive --partial --progress --delete-during --stats"

#=======
### Recommencer les tests si la touche R a été préssée 
REPLY="r"
while [[ $REPLY = [rR] ]]; do
    msg="\n"
    erreurs=0
    for idx in ${!tblMntPnts[@]}; do
        msg+="${tblColoMsg[${idx}]}Le point de mountage\t${STNDT}${tblMntPnts[${idx}]} ${INVRT}"
        if mountpoint -q "${tblMntPnts[${idx}]}"; then
            msg+="${VERT} est bien un point de mountage accessible."
        else
            erreurs=1
            msg+="${ROUGE} n'est pas un point de mountage."
        fi
        msg+="${STNDT}\n"

        msg+="${tblColoMsg[${idx}]}Le répertoire\t\t${STNDT}${tblMntPnts[${idx}]}${tblTrgDirs[${idx}]} ${INVRT}"
        if test -w "${tblMntPnts[${idx}]}${tblTrgDirs[${idx}]}"; then
            msg+="${VERT} est OK."
        else
            erreurs=1
            msg+="${ROUGE} n'est pas accessible en écriture."
        fi
        msg+="${STNDT}\n\n"
    done
    echo -e "${msg}"
    ### Si erreur trouvée => Dialogue
    if test $erreurs = 1; then
        echo -e "${INVRT}${VERT}P${STNDT}oursuivre la Sauvegarde, ${INVRT}${VERT}Q${STNDT}uitter (ou autre touche), ${INVRT}${VERT}R${STNDT}ecommencer.\n"
        read -sn1
        [[ $REPLY = [qQ] ]] && { echo -e "${ROUGE}Abandon sauvegarde.${STNDT}\nSortie Sauvegarde\n"; exit; }
    else
       REPLY="P"
    fi
done

### Fonction pour options et arguments de rsync
optsArgsForRsync() {
    printf %s "${optsRsync} "
    IFS=";"
    for myDir in ${tblSrcDirs[${1}]}; do
        printf %s "--include=\"${myDir}***\" "
    done
#    printf %s "--exclude=\"*\" ${tblSrcRoot[${1}]} ${tblMntPnts[${1}]}${tblTrgDirs[${1}]}"
}

### Sauvegardes
for idx in ${!tblNomSauv[@]}; do
    echo -e "${tblColoMsg[${idx}]}=========================================\nSynchronisation en cours pour ${tblNomSauv[${idx}]}..."
    rsync $(optsArgsForRsync ${idx})  2>> "${backup}"
done

### Messages de fin
maDate="$(date +'le : '%d-%m-%Y' à '%T)"
echo -e "${STNDT}============================================"
echo -e "Sauvegarde terminée ${maDate}"
echo "${maDate}" >> "${backup}"
.



et le fichier backup, qui paraît toujours aussi mécontent :

Code : Tout sélectionner

rsync  version 3.1.2  protocol version 31
Copyright (C) 1996-2015 by Andrew Tridgell, Wayne Davison, and others.
Web site: http://rsync.samba.org/
Capabilities:
    64-bit files, 64-bit inums, 64-bit timestamps, 64-bit long ints,
    socketpairs, hardlinks, symlinks, IPv6, batchfiles, inplace,
    append, ACLs, xattrs, iconv, symtimes, prealloc

rsync comes with ABSOLUTELY NO WARRANTY.  This is free software, and you
are welcome to redistribute it under certain conditions.  See the GNU
General Public Licence for details.

rsync is a file transfer program capable of efficient remote update
via a fast differencing algorithm.

Usage: rsync [OPTION]... SRC [SRC]... DEST
  or   rsync [OPTION]... SRC [SRC]... [USER@]HOST:DEST
  or   rsync [OPTION]... SRC [SRC]... [USER@]HOST::DEST
  or   rsync [OPTION]... SRC [SRC]... rsync://[USER@]HOST[:PORT]/DEST
  or   rsync [OPTION]... [USER@]HOST:SRC [DEST]
  or   rsync [OPTION]... [USER@]HOST::SRC [DEST]
  or   rsync [OPTION]... rsync://[USER@]HOST[:PORT]/SRC [DEST]
The ':' usages connect via remote shell, while '::' & 'rsync://' usages connect
to an rsync daemon, and require SRC or DEST to start with a module name.

Options
 -v, --verbose               increase verbosity
     --info=FLAGS            fine-grained informational verbosity
     --debug=FLAGS           fine-grained debug verbosity
     --msgs2stderr           special output handling for debugging
 -q, --quiet                 suppress non-error messages
     --no-motd               suppress daemon-mode MOTD (see manpage caveat)
 -c, --checksum              skip based on checksum, not mod-time & size
 -a, --archive               archive mode; equals -rlptgoD (no -H,-A,-X)
     --no-OPTION             turn off an implied OPTION (e.g. --no-D)
 -r, --recursive             recurse into directories
 -R, --relative              use relative path names
     --no-implied-dirs       don't send implied dirs with --relative
 -b, --backup                make backups (see --suffix & --backup-dir)
     --backup-dir=DIR        make backups into hierarchy based in DIR
     --suffix=SUFFIX         set backup suffix (default ~ w/o --backup-dir)
 -u, --update                skip files that are newer on the receiver
     --inplace               update destination files in-place (SEE MAN PAGE)
     --append                append data onto shorter files
     --append-verify         like --append, but with old data in file checksum
 -d, --dirs                  transfer directories without recursing
 -l, --links                 copy symlinks as symlinks
 -L, --copy-links            transform symlink into referent file/dir
     --copy-unsafe-links     only "unsafe" symlinks are transformed
     --safe-links            ignore symlinks that point outside the source tree
     --munge-links           munge symlinks to make them safer (but unusable)
 -k, --copy-dirlinks         transform symlink to a dir into referent dir
 -K, --keep-dirlinks         treat symlinked dir on receiver as dir
 -H, --hard-links            preserve hard links
 -p, --perms                 preserve permissions
 -E, --executability         preserve the file's executability
     --chmod=CHMOD           affect file and/or directory permissions
 -A, --acls                  preserve ACLs (implies --perms)
 -X, --xattrs                preserve extended attributes
 -o, --owner                 preserve owner (super-user only)
 -g, --group                 preserve group
     --devices               preserve device files (super-user only)
     --copy-devices          copy device contents as regular file
     --specials              preserve special files
 -D                          same as --devices --specials
 -t, --times                 preserve modification times
 -O, --omit-dir-times        omit directories from --times
 -J, --omit-link-times       omit symlinks from --times
     --super                 receiver attempts super-user activities
     --fake-super            store/recover privileged attrs using xattrs
 -S, --sparse                handle sparse files efficiently
     --preallocate           allocate dest files before writing them
 -n, --dry-run               perform a trial run with no changes made
 -W, --whole-file            copy files whole (without delta-xfer algorithm)
 -x, --one-file-system       don't cross filesystem boundaries
 -B, --block-size=SIZE       force a fixed checksum block-size
 -e, --rsh=COMMAND           specify the remote shell to use
     --rsync-path=PROGRAM    specify the rsync to run on the remote machine
     --existing              skip creating new files on receiver
     --ignore-existing       skip updating files that already exist on receiver
     --remove-source-files   sender removes synchronized files (non-dirs)
     --del                   an alias for --delete-during
     --delete                delete extraneous files from destination dirs
     --delete-before         receiver deletes before transfer, not during
     --delete-during         receiver deletes during the transfer
     --delete-delay          find deletions during, delete after
     --delete-after          receiver deletes after transfer, not during
     --delete-excluded       also delete excluded files from destination dirs
     --ignore-missing-args   ignore missing source args without error
     --delete-missing-args   delete missing source args from destination
     --ignore-errors         delete even if there are I/O errors
     --force                 force deletion of directories even if not empty
     --max-delete=NUM        don't delete more than NUM files
     --max-size=SIZE         don't transfer any file larger than SIZE
     --min-size=SIZE         don't transfer any file smaller than SIZE
     --partial               keep partially transferred files
     --partial-dir=DIR       put a partially transferred file into DIR
     --delay-updates         put all updated files into place at transfer's end
 -m, --prune-empty-dirs      prune empty directory chains from the file-list
     --numeric-ids           don't map uid/gid values by user/group name
     --usermap=STRING        custom username mapping
     --groupmap=STRING       custom groupname mapping
     --chown=USER:GROUP      simple username/groupname mapping
     --timeout=SECONDS       set I/O timeout in seconds
     --contimeout=SECONDS    set daemon connection timeout in seconds
 -I, --ignore-times          don't skip files that match in size and mod-time
 -M, --remote-option=OPTION  send OPTION to the remote side only
     --size-only             skip files that match in size
     --modify-window=NUM     compare mod-times with reduced accuracy
 -T, --temp-dir=DIR          create temporary files in directory DIR
 -y, --fuzzy                 find similar file for basis if no dest file
     --compare-dest=DIR      also compare destination files relative to DIR
     --copy-dest=DIR         ... and include copies of unchanged files
     --link-dest=DIR         hardlink to files in DIR when unchanged
 -z, --compress              compress file data during the transfer
     --compress-level=NUM    explicitly set compression level
     --skip-compress=LIST    skip compressing files with a suffix in LIST
 -C, --cvs-exclude           auto-ignore files the same way CVS does
 -f, --filter=RULE           add a file-filtering RULE
 -F                          same as --filter='dir-merge /.rsync-filter'
                             repeated: --filter='- .rsync-filter'
     --exclude=PATTERN       exclude files matching PATTERN
     --exclude-from=FILE     read exclude patterns from FILE
     --include=PATTERN       don't exclude files matching PATTERN
     --include-from=FILE     read include patterns from FILE
     --files-from=FILE       read list of source-file names from FILE
 -0, --from0                 all *-from/filter files are delimited by 0s
 -s, --protect-args          no space-splitting; only wildcard special-chars
     --address=ADDRESS       bind address for outgoing socket to daemon
     --port=PORT             specify double-colon alternate port number
     --sockopts=OPTIONS      specify custom TCP options
     --blocking-io           use blocking I/O for the remote shell
     --stats                 give some file-transfer stats
 -8, --8-bit-output          leave high-bit chars unescaped in output
 -h, --human-readable        output numbers in a human-readable format
     --progress              show progress during transfer
 -P                          same as --partial --progress
 -i, --itemize-changes       output a change-summary for all updates
     --out-format=FORMAT     output updates using the specified FORMAT
     --log-file=FILE         log what we're doing to the specified FILE
     --log-file-format=FMT   log updates using the specified FMT
     --password-file=FILE    read daemon-access password from FILE
     --list-only             list the files instead of copying them
     --bwlimit=RATE          limit socket I/O bandwidth
     --stop-at=y-m-dTh:m     Stop rsync at year-month-dayThour:minute
     --time-limit=MINS       Stop rsync after MINS minutes have elapsed
     --outbuf=N|L|B          set output buffering to None, Line, or Block
     --write-batch=FILE      write a batched update to FILE
     --only-write-batch=FILE like --write-batch but w/o updating destination
     --read-batch=FILE       read a batched update from FILE
     --protocol=NUM          force an older protocol version to be used
     --iconv=CONVERT_SPEC    request charset conversion of filenames
     --checksum-seed=NUM     set block/file checksum seed (advanced)
     --noatime               do not alter atime when opening source files
 -4, --ipv4                  prefer IPv4
 -6, --ipv6                  prefer IPv6
     --version               print version number
(-h) --help                  show this help (-h is --help only if used alone)

Use "rsync --daemon --help" to see the daemon-mode command-line options.
Please see the rsync(1) and rsyncd.conf(5) man pages for full documentation.
See http://rsync.samba.org/ for updates, bug reports, and answers
rsync error: syntax or usage error (code 1) at main.c(1653) [Receiver=3.1.2]
le : 06-10-2017 à 19:14:06 
.


en fenêtre de commande, c'est très sibyllin...

Code : Tout sélectionner

bernard-portable:/home/bernard# /home/bernard/MesScripts/Sauvegarde_portable_Sauv1T_500go_SSD224Go_6-partiel1

Le point de mountage	/media/bernard/SSD224Go/  est bien un point de mountage accessible.
Le répertoire		/media/bernard/SSD224Go/  est OK.


=========================================
Synchronisation en cours pour SSD224Go...
============================================
Sauvegarde terminée le : 06-10-2017 à 19:14:06
bernard-portable:/home/bernard# 
.
et je confirme, il n'a rien sauvegardé...

facile à vérifier, j'ai bougé des fichier dans le dossier "mes scripts"... :icon_confused:
Cordialement,
Bernard
Debian9.1Stretch-XFCE-64bits-Sony-Vaio,Intel-P8400-2.26GHz,DD-SeagateSSHD500Go,GeForce9300M-GS-256Mo
MicP
Modérateur
Modérateur
Messages : 896
Inscription : 16 avr. 2016, 22:14
Status : Hors-ligne

Il te faudrait supprimer le caractère # qui est en début de la ligne suivante

Code : Tout sélectionner

#    printf %s "--exclude=\"*\" ${tblSrcRoot[${1}]} ${tblMntPnts[${1}]}${tblTrgDirs[${1}]}"


=======
Et, d'autre part, je viens de me rendre compte qu'il faudrait aussi remplacer

Code : Tout sélectionner

       [[ $REPLY = [qQ] ]] && { echo -e "${ROUGE}Abandon sauvegarde.${STNDT}\nSortie Sauvegarde\n"; exit; }
par

Code : Tout sélectionner

       [[ $REPLY != [pPrR] ]] && { echo -e "${ROUGE}Abandon sauvegarde.${STNDT}\nSortie Sauvegarde\n"; exit; }
=======
Mais je dois être fatigué : je n'arrive plus à faire fonctionner l'option "exclude"
Avatar de l’utilisateur
DbFr871
Membre très actif
Membre très actif
Messages : 1140
Inscription : 17 mai 2016, 20:48
Localisation : Nègrepelissien
Contact :
Status : Hors-ligne

MicP a écrit : 06 oct. 2017, 20:59 Il te faudrait supprimer le caractère # qui est en début de la ligne suivante

Code : Tout sélectionner

#    printf %s "--exclude=\"*\" ${tblSrcRoot[${1}]} ${tblMntPnts[${1}]}${tblTrgDirs[${1}]}"


=======
Et, d'autre part, je viens de me rendre compte qu'il faudrait aussi remplacer

Code : Tout sélectionner

       [[ $REPLY = [qQ] ]] && { echo -e "${ROUGE}Abandon sauvegarde.${STNDT}\nSortie Sauvegarde\n"; exit; }
par

Code : Tout sélectionner

       [[ $REPLY != [pPrR] ]] && { echo -e "${ROUGE}Abandon sauvegarde.${STNDT}\nSortie Sauvegarde\n"; exit; }
=======
Mais je dois être fatigué : je n'arrive plus à faire fonctionner l'option "exclude"
.
Je te comprends pour la fatigue... même sur un écran "confortable", un 32" cela m'est "pénible"...

Pour le # j'avais commenté la ligne, justement pour qu'elle ne fonctionne plus... et ça ne fonctionne tellement plus, que le script ne sauvegarde plus... :rofl:

je vais insérer la ligne que tu as modifiée, et viendrai t'informer :wink:
Cordialement,
Bernard
Debian9.1Stretch-XFCE-64bits-Sony-Vaio,Intel-P8400-2.26GHz,DD-SeagateSSHD500Go,GeForce9300M-GS-256Mo
Avatar de l’utilisateur
DbFr871
Membre très actif
Membre très actif
Messages : 1140
Inscription : 17 mai 2016, 20:48
Localisation : Nègrepelissien
Contact :
Status : Hors-ligne

en décommentant la ligne voilà ce qu'il recommence :

Code : Tout sélectionner

bernard-portable:/home/bernard# /home/bernard/MesScripts/Sauvegarde_portable_Sauv1T_500go_SSD224Go_6-partiel

Le point de mountage	/media/bernard/SSD224Go/  est bien un point de mountage accessible.
Le répertoire		/media/bernard/SSD224Go/  est OK.


=========================================
Synchronisation en cours pour SSD224Go...
sending incremental file list
.xsession-errors
        436,664 100%   29.63MB/s    0:00:00 (xfr#1, ir-chk=9784/9805)
.cache/chromium/Default/Cache/
.cache/chromium/Default/Cache/0db838c95dee1377_0
         61,063 100%  292.31kB/s    0:00:00 (xfr#2, ir-chk=16444/17659)
.cache/chromium/Default/Cache/10942621c3c35d31_1
            134 100%    0.64kB/s    0:00:00 (xfr#3, ir-chk=16348/17659)
.
il sauvegarde tout... :icon_confused:

et voici ce qui est écrit dans le backup :

Code : Tout sélectionner

rsync error: received SIGINT, SIGTERM, or SIGHUP (code 20) at rsync.c(638) [sender=3.1.2]
rsync: [sender] write error: Broken pipe (32)
le : 06-10-2017 à 22:52:27
.
si cela peut t'aider...
Cordialement,
Bernard
Debian9.1Stretch-XFCE-64bits-Sony-Vaio,Intel-P8400-2.26GHz,DD-SeagateSSHD500Go,GeForce9300M-GS-256Mo
MicP
Modérateur
Modérateur
Messages : 896
Inscription : 16 avr. 2016, 22:14
Status : Hors-ligne

Bonjour

Après quelques essais, je constate que, depuis le début, il y a un problème dans ma proposition de script
concernant la méthode d'insertion par une variable contenant la suite des --include="repertoire/***" dans la ligne de commande.

Je vais trouver une solution, mais il me faut faire d'abord quelques essais pour être sûr.

Voilà :

Code : Tout sélectionner

#!/bin/bash

### Nom du fichier qui va recevoir les messages d'erreurs de rsync
backup="/home/bernard/bin/Sauvegardes/backuperror0Del-portable_Sauv1T_500go_SSD224Go_6-partiel1.log"

### Options rsync
optsRsync="--archive --partial --progress --stats"

### Couleurs
INVRT="\\033[7m"
STNDT="\\033[0;39m"
ROUGE="\\033[1;31m"
BLANC="\\033[0;02m"
JAUNE="\\033[1;33m"
BLEU="\\033[1;34m"
VERT="\\033[1;32m"
ROSE="\\033[1;35m"
CYAN="\\033[1;36m"

### Tableaux
tblNomSauv=( "SSD224Go"                                             )
tblColoMsg=( "${CYAN}"                                              )
tblMntPnts=( "/media/bernard/SSD224Go/"                             )
tblTrgDirs=( ""                                                     )
tblSrcRoot=( "/home/bernard/"                                       )
tblSrcDirs=( "MesPhotos/;MesDocuments/;DocumentsPerso/;MesScripts/" )

### Recommencer les tests si la touche R a été préssée 
REPLY="r"
while [[ $REPLY = [rR] ]]; do
    msg="\n"
    erreurs=0
    for idx in ${!tblMntPnts[@]}; do
        msg+="${tblColoMsg[${idx}]}Le point de mountage\t${STNDT}${tblMntPnts[${idx}]} ${INVRT}"
        if mountpoint -q "${tblMntPnts[${idx}]}"; then
            msg+="${VERT} est bien un point de mountage accessible."
        else
            erreurs=1
            msg+="${ROUGE} n'est pas un point de mountage."
        fi
        msg+="${STNDT}\n"

        msg+="${tblColoMsg[${idx}]}Le répertoire\t\t${STNDT}${tblMntPnts[${idx}]}${tblTrgDirs[${idx}]} ${INVRT}"
        if test -w "${tblMntPnts[${idx}]}${tblTrgDirs[${idx}]}"; then
            msg+="${VERT} est OK."
        else
            erreurs=1
            msg+="${ROUGE} n'est pas accessible en écriture."
        fi
        msg+="${STNDT}\n\n"
    done
    echo -e "${msg}"
    ### Si erreur trouvée => Dialogue
    if test $erreurs = 1; then
        echo -e "${INVRT}${VERT}P${STNDT}oursuivre la Sauvegarde, ${INVRT}${VERT}Q${STNDT}uitter (ou autre touche), ${INVRT}${VERT}R${STNDT}ecommencer.\n"
        read -sn1
        [[ $REPLY != [pPrR] ]] && { echo -e "${ROUGE}Abandon sauvegarde.${STNDT}\nSortie Sauvegarde\n"; exit; }
    else
       REPLY="P"
    fi
done

### Sauvegarde(s)
for idx in ${!tblNomSauv[@]}; do
    echo -e "${tblColoMsg[${idx}]}=========================================\nSynchronisation en cours pour ${tblNomSauv[${idx}]}..."
    echo -e "+ ${tblSrcDirs[${idx}]//;/***\\n+ }***\n- *" |  \
        rsync ${optsRsync} --include-from=- "${tblSrcRoot[${idx}]}" "${tblMntPnts[${idx}]}${tblTrgDirs[${idx}]}" 2>> "${backup}"
done

### Message de fin
echo -e "${STNDT}============================================\nSauvegarde terminée $(date +'le : '%d-%m-%Y' à '%T)"
echo "$(date)" >> "${backup}"
NOTE : Avec ce script, pour chaque élément de chaque liste du tableau tblSrcDirs
le chemin indiqué ne doit pas avoir de sous-répertoires <=> un seul caractère /
(comme c'est le cas actuellement)

En d'autre termes :
MesPhotos/           => c'est bon

MesPhotos/Courchevel/  => c'est PAS bon car il y a un sous-répertoire.
Avatar de l’utilisateur
DbFr871
Membre très actif
Membre très actif
Messages : 1140
Inscription : 17 mai 2016, 20:48
Localisation : Nègrepelissien
Contact :
Status : Hors-ligne

Bonsoir :icon_biggrin:

Je viens de le tester, et comme il fonctionne correctement "à mon avis"... j'ai ajouté les 2 autres supports, et... ça fonctionne :icon_biggrin:

Voici le script tel que je l'ai modifié :

Code : Tout sélectionner

#!/bin/bash

### Nom du fichier qui va recevoir les messages d'erreurs de rsync
backup="/home/bernard/bin/Sauvegardes/backuperror0Del-portable_Sauv1T_500go_SSD224Go_Test3-complet.log"

### Options rsync
optsRsync="--archive --partial --progress --delete-during --stats"

### Couleurs
INVRT="\\033[7m"
STNDT="\\033[0;39m"
ROUGE="\\033[1;31m"
BLANC="\\033[0;02m"
JAUNE="\\033[1;33m"
BLEU="\\033[1;34m"
VERT="\\033[1;32m"
ROSE="\\033[1;35m"
CYAN="\\033[1;36m"

### Tableaux
tblNomSauv=( "SSD224Go"                                              "DD1To"                      "DD500Go"           )
tblColoMsg=( "${CYAN}"                                               "${ROSE}"                    "${BLEU}"           )
tblMntPnts=( "/media/bernard/SSD224Go/"                              "/media/bernard/Sauv1To-a/"  "/media/usb0/"      )
tblTrgDirs=( ""                                                      "SauvDdPrincipal1/"          "SauvDdPrincipal2/" )
tblSrcRoot=( "/home/bernard/"                                        "/"                          "/"                 )
tblSrcDirs=( "MesPhotos/;MesDocuments/;DocumentsPerso/;MesScripts/"  "home/;etc/"                 "home/;etc/"        )

### Recommencer les tests si la touche R a été pressée 
REPLY="r"
while [[ $REPLY = [rR] ]]; do
    msg="\n"
    erreurs=0
    for idx in ${!tblMntPnts[@]}; do
        msg+="${tblColoMsg[${idx}]}Le point de mountage\t${STNDT}${tblMntPnts[${idx}]} ${INVRT}"
        if mountpoint -q "${tblMntPnts[${idx}]}"; then
            msg+="${VERT} est bien un point de mountage accessible."
        else
            erreurs=1
            msg+="${ROUGE} n'est pas un point de mountage."
        fi
        msg+="${STNDT}\n"

        msg+="${tblColoMsg[${idx}]}Le répertoire\t\t${STNDT}${tblMntPnts[${idx}]}${tblTrgDirs[${idx}]} ${INVRT}"
        if test -w "${tblMntPnts[${idx}]}${tblTrgDirs[${idx}]}"; then
            msg+="${VERT} est OK."
        else
            erreurs=1
            msg+="${ROUGE} n'est pas accessible en écriture."
        fi
        msg+="${STNDT}\n\n"
    done
    echo -e "${msg}"
    ### Si erreur trouvée => Dialogue
    if test $erreurs = 1; then
        echo -e "${INVRT}${VERT}P${STNDT}oursuivre la Sauvegarde, ${INVRT}${VERT}Q${STNDT}uitter (ou autre touche), ${INVRT}${VERT}R${STNDT}ecommencer.\n"
        read -sn1
        [[ $REPLY != [pPrR] ]] && { echo -e "${ROUGE}Abandon sauvegarde.${STNDT}\nSortie Sauvegarde\n"; exit; }
    else
       REPLY="P"
    fi
done

### Sauvegarde(s)
for idx in ${!tblNomSauv[@]}; do
    echo -e "${tblColoMsg[${idx}]}=========================================\nSynchronisation en cours pour ${tblNomSauv[${idx}]}..."
    echo -e "+ ${tblSrcDirs[${idx}]//;/***\\n+ }***\n- *" |  \
        rsync ${optsRsync} --include-from=- "${tblSrcRoot[${idx}]}" "${tblMntPnts[${idx}]}${tblTrgDirs[${idx}]}" 2>> "${backup}"
done

### Message de fin
echo -e "${STNDT}============================================\nSauvegarde terminée $(date +'le : '%d-%m-%Y' à '%T)"
echo "$(date)" >> "${backup}"
.

son fichier backup :
samedi 7 octobre 2017, 20:24:41 (UTC+0200)

les commandes en console :

Code : Tout sélectionner

bernard-portable:/home/bernard# /home/bernard/MesScripts/Sauvegarde_portable_Sauv1T_500go_SSD224Go_Test3-complet

Le point de mountage	/media/bernard/SSD224Go/  est bien un point de mountage accessible.
Le répertoire		/media/bernard/SSD224Go/  est OK.

Le point de mountage	/media/bernard/Sauv1To-a/  est bien un point de mountage accessible.
Le répertoire		/media/bernard/Sauv1To-a/SauvDdPrincipal1/  est OK.

Le point de mountage	/media/usb0/  est bien un point de mountage accessible.
Le répertoire		/media/usb0/SauvDdPrincipal2/  est OK.


=========================================
Synchronisation en cours pour SSD224Go...
sending incremental file list
deleting MesScripts/EvolutionScript1/.~lock.ComparaisonScripts1.odt#
MesScripts/
MesScripts/Sauvegarde_portable_Sauv1T_500go_SSD224Go_Test3-complet

...

Total bytes sent: 45,570,756
Total bytes received: 22,697

sent 45,570,756 bytes  received 22,697 bytes  6,079,127.07 bytes/sec
total size is 251,352,404,257  speedup is 5,512.91
============================================
Sauvegarde terminée le : 07-10-2017 à 20:24:41
bernard-portable:/home/bernard# 
.
Je teste toute cette fin de semaine, et je passerai en résolu début de semaine prochaine... si tu le veux bien :wink:
sauf... si tu vois quelque chose qui te chiffonne... :wink:
Cordialement,
Bernard
Debian9.1Stretch-XFCE-64bits-Sony-Vaio,Intel-P8400-2.26GHz,DD-SeagateSSHD500Go,GeForce9300M-GS-256Mo
Répondre