Différences
Ci-dessous, les différences entre deux révisions de la page.
Prochaine révision | Révision précédente | ||
elearning:workbooks:centos:8:lcf800:l702 [2023/07/14 10:48] – created admin | elearning:workbooks:centos:8:lcf800:l702 [2023/07/14 10:56] (Version actuelle) – admin | ||
---|---|---|---|
Ligne 31: | Ligne 31: | ||
* Configuration | * Configuration | ||
* LAB #1 - Gérer les Utilisateurs et les Groupes | * LAB #1 - Gérer les Utilisateurs et les Groupes | ||
- | * LAB #2 - Forcer l' | + | |
- | * Utiliser des Mots de Passe Complexe | + | * Préparation |
- | * Configuration | + | * La Commande tar |
- | * su et su - | + | * Présentation |
- | * sudo | + | |
+ | * La Commande GPL tar et la Compression | ||
+ | * La Commande cpio | ||
+ | * Présentation | ||
+ | * LAB #3 - Travailler avec la Commande cpio | ||
+ | * La Commande dd | ||
+ | * Présentation | ||
+ | * LAB #4 - Travailler avec la Commande dd | ||
+ | * Les Commandes dump et restore | ||
+ | * Présentation | ||
=====Présentation===== | =====Présentation===== | ||
Ligne 1040: | Ligne 1049: | ||
</ | </ | ||
+ | =====Outils classiques de sauvegarde===== | ||
+ | ====Préparation==== | ||
+ | |||
+ | Afin de poursuivre, il convient de créer une arborescence à sauvegarder : | ||
+ | |||
+ | < | ||
+ | [root@centos8 ~]# mkdir -p /test/repY; mkdir /test/repZ | ||
+ | [root@centos8 ~]# cd /test/repY; touch Y1 Y2 Y3 | ||
+ | [root@centos8 repY]# cd /test/repZ; touch Z1 Z2 | ||
+ | [root@centos8 repZ]# ls -lR /test | ||
+ | /test: | ||
+ | total 0 | ||
+ | drwxr-xr-x. 2 root root 36 Jun 2 14:05 repY | ||
+ | drwxr-xr-x. 2 root root 26 Jun 2 14:05 repZ | ||
+ | |||
+ | /test/repY: | ||
+ | total 0 | ||
+ | -rw-r--r--. 1 root root 0 Jun 2 14:05 Y1 | ||
+ | -rw-r--r--. 1 root root 0 Jun 2 14:05 Y2 | ||
+ | -rw-r--r--. 1 root root 0 Jun 2 14:05 Y3 | ||
+ | |||
+ | /test/repZ: | ||
+ | total 0 | ||
+ | -rw-r--r--. 1 root root 0 Jun 2 14:05 Z1 | ||
+ | -rw-r--r--. 1 root root 0 Jun 2 14:05 Z2 | ||
+ | </ | ||
+ | |||
+ | ====La Commande tar==== | ||
+ | |||
+ | ===Présentation=== | ||
+ | |||
+ | Le programme **tar** a été originellement prévu pour sauvegarder sur des bandes magnétiques, | ||
+ | |||
+ | La commande **tar** peut sauvegarder vers : | ||
+ | |||
+ | * un fichier spécial, par exemple le nom d'un lecteur de bande, | ||
+ | * un fichier ordinaire sur disque, | ||
+ | * la sortie standard pour être utilisé dans un pipe. | ||
+ | |||
+ | ===Options de la Commande=== | ||
+ | |||
+ | Les options de la commande tar sont : | ||
+ | |||
+ | < | ||
+ | [root@centos8 repZ]# tar --help | ||
+ | Usage: tar [OPTION...] [FILE]... | ||
+ | GNU ' | ||
+ | restore individual files from the archive. | ||
+ | |||
+ | Examples: | ||
+ | tar -cf archive.tar foo bar # Create archive.tar from files foo and bar. | ||
+ | tar -tvf archive.tar | ||
+ | tar -xf archive.tar | ||
+ | |||
+ | Local file name selection: | ||
+ | |||
+ | --add-file=FILE | ||
+ | | ||
+ | -C, --directory=DIR | ||
+ | --exclude=PATTERN | ||
+ | --exclude-backups | ||
+ | --exclude-caches | ||
+ | | ||
+ | --exclude-caches-all | ||
+ | --exclude-caches-under exclude everything under directories containing | ||
+ | | ||
+ | --exclude-ignore=FILE | ||
+ | FILE, if it exists | ||
+ | --exclude-ignore-recursive=FILE | ||
+ | read exclude patterns for each directory and its | ||
+ | | ||
+ | --exclude-tag=FILE | ||
+ | | ||
+ | --exclude-tag-all=FILE exclude directories containing FILE | ||
+ | --exclude-tag-under=FILE | ||
+ | | ||
+ | --exclude-vcs | ||
+ | --exclude-vcs-ignores | ||
+ | --no-null | ||
+ | --no-recursion | ||
+ | --no-unquote | ||
+ | --no-verbatim-files-from | ||
+ | | ||
+ | --null | ||
+ | | ||
+ | --recursion | ||
+ | -T, --files-from=FILE | ||
+ | --unquote | ||
+ | --verbatim-files-from | ||
+ | | ||
+ | -X, --exclude-from=FILE | ||
+ | |||
+ | File name matching options (affect both exclude and include patterns): | ||
+ | |||
+ | --anchored | ||
+ | --ignore-case | ||
+ | --no-anchored | ||
+ | | ||
+ | --no-ignore-case | ||
+ | --no-wildcards | ||
+ | --no-wildcards-match-slash | ||
+ | --wildcards | ||
+ | --wildcards-match-slash | ||
+ | |||
+ | Main operation mode: | ||
+ | |||
+ | -A, --catenate, --concatenate | ||
+ | -c, --create | ||
+ | -d, --diff, --compare | ||
+ | --delete | ||
+ | -r, --append | ||
+ | -t, --list | ||
+ | --test-label | ||
+ | -u, --update | ||
+ | -x, --extract, --get | ||
+ | |||
+ | | ||
+ | |||
+ | --check-device | ||
+ | | ||
+ | -g, --listed-incremental=FILE | ||
+ | -G, --incremental | ||
+ | --hole-detection=TYPE | ||
+ | --ignore-failed-read | ||
+ | --level=NUMBER | ||
+ | -n, --seek | ||
+ | --no-check-device | ||
+ | | ||
+ | --no-seek | ||
+ | --occurrence[=NUMBER] | ||
+ | in the archive; this option is valid only in | ||
+ | | ||
+ | | ||
+ | files is given either on the command line or via | ||
+ | the -T option; NUMBER defaults to 1 | ||
+ | --sparse-version=MAJOR[.MINOR] | ||
+ | set version of the sparse format to use (implies | ||
+ | | ||
+ | -S, --sparse | ||
+ | |||
+ | | ||
+ | |||
+ | -k, --keep-old-files | ||
+ | treat them as errors | ||
+ | --keep-directory-symlink | ||
+ | | ||
+ | --keep-newer-files | ||
+ | their archive copies | ||
+ | --no-overwrite-dir | ||
+ | --one-top-level[=DIR] | ||
+ | | ||
+ | --overwrite | ||
+ | --overwrite-dir | ||
+ | | ||
+ | --recursive-unlink | ||
+ | --remove-files | ||
+ | --skip-old-files | ||
+ | | ||
+ | -U, --unlink-first | ||
+ | -W, --verify | ||
+ | |||
+ | | ||
+ | |||
+ | --ignore-command-error ignore exit codes of children | ||
+ | --no-ignore-command-error | ||
+ | error | ||
+ | -O, --to-stdout | ||
+ | --to-command=COMMAND | ||
+ | |||
+ | | ||
+ | |||
+ | --atime-preserve[=METHOD] | ||
+ | by restoring the times after reading | ||
+ | | ||
+ | times in the first place (METHOD=' | ||
+ | --clamp-mtime | ||
+ | what was given with --mtime | ||
+ | --delay-directory-restore | ||
+ | | ||
+ | of extraction | ||
+ | --group=NAME | ||
+ | --group-map=FILE | ||
+ | --mode=CHANGES | ||
+ | --mtime=DATE-OR-FILE | ||
+ | -m, --touch | ||
+ | --no-delay-directory-restore | ||
+ | | ||
+ | | ||
+ | --no-same-owner | ||
+ | | ||
+ | --no-same-permissions | ||
+ | from the archive (default for ordinary users) | ||
+ | --numeric-owner | ||
+ | --owner=NAME | ||
+ | --owner-map=FILE | ||
+ | -p, --preserve-permissions, | ||
+ | | ||
+ | | ||
+ | --same-owner | ||
+ | | ||
+ | -s, --preserve-order, | ||
+ | | ||
+ | the files in the archive | ||
+ | --sort=ORDER | ||
+ | inode | ||
+ | |||
+ | | ||
+ | |||
+ | --acls | ||
+ | --no-acls | ||
+ | --no-selinux | ||
+ | --no-xattrs | ||
+ | --selinux | ||
+ | --xattrs | ||
+ | --xattrs-exclude=MASK | ||
+ | --xattrs-include=MASK | ||
+ | |||
+ | | ||
+ | |||
+ | -f, --file=ARCHIVE | ||
+ | --force-local | ||
+ | -F, --info-script=NAME, | ||
+ | run script at end of each tape (implies -M) | ||
+ | -L, --tape-length=NUMBER | ||
+ | -M, --multi-volume | ||
+ | --rmt-command=COMMAND | ||
+ | --rsh-command=COMMAND | ||
+ | --volno-file=FILE | ||
+ | |||
+ | | ||
+ | |||
+ | -b, --blocking-factor=BLOCKS | ||
+ | -B, --read-full-records | ||
+ | -i, --ignore-zeros | ||
+ | --record-size=NUMBER | ||
+ | |||
+ | | ||
+ | |||
+ | -H, --format=FORMAT | ||
+ | |||
+ | | ||
+ | |||
+ | gnu GNU tar 1.13.x format | ||
+ | oldgnu | ||
+ | pax POSIX 1003.1-2001 (pax) format | ||
+ | posix same as pax | ||
+ | ustar POSIX 1003.1-1988 (ustar) format | ||
+ | v7 old V7 tar format | ||
+ | |||
+ | --old-archive, | ||
+ | same as --format=v7 | ||
+ | --pax-option=keyword[[: | ||
+ | | ||
+ | --posix | ||
+ | -V, --label=TEXT | ||
+ | | ||
+ | for volume name | ||
+ | |||
+ | | ||
+ | |||
+ | -a, --auto-compress | ||
+ | | ||
+ | -I, --use-compress-program=PROG | ||
+ | | ||
+ | -j, --bzip2 | ||
+ | -J, --xz | ||
+ | --lzip | ||
+ | --lzma | ||
+ | --lzop | ||
+ | --no-auto-compress | ||
+ | | ||
+ | -z, --gzip, --gunzip, --ungzip | ||
+ | -Z, --compress, --uncompress | ||
+ | |||
+ | Local file selection: | ||
+ | |||
+ | --backup[=CONTROL] | ||
+ | -h, --dereference | ||
+ | point to | ||
+ | --hard-dereference | ||
+ | refer to | ||
+ | -K, --starting-file=MEMBER-NAME | ||
+ | begin at member MEMBER-NAME when reading the | ||
+ | | ||
+ | --newer-mtime=DATE | ||
+ | -N, --newer=DATE-OR-FILE, | ||
+ | only store files newer than DATE-OR-FILE | ||
+ | --one-file-system | ||
+ | -P, --absolute-names | ||
+ | --suffix=STRING | ||
+ | | ||
+ | | ||
+ | |||
+ | File name transformations: | ||
+ | |||
+ | --strip-components=NUMBER | ||
+ | names on extraction | ||
+ | --transform=EXPRESSION, | ||
+ | use sed replace EXPRESSION to transform file | ||
+ | names | ||
+ | |||
+ | | ||
+ | |||
+ | --checkpoint[=NUMBER] | ||
+ | | ||
+ | --checkpoint-action=ACTION | ||
+ | --full-time | ||
+ | --index-file=FILE | ||
+ | -l, --check-links | ||
+ | --no-quote-chars=STRING | ||
+ | --quote-chars=STRING | ||
+ | --quoting-style=STYLE | ||
+ | | ||
+ | -R, --block-number | ||
+ | | ||
+ | --show-defaults | ||
+ | --show-omitted-dirs | ||
+ | that does not match search criteria | ||
+ | --show-snapshot-field-ranges | ||
+ | show valid ranges for snapshot-file fields | ||
+ | --show-transformed-names, | ||
+ | show file or archive names after transformation | ||
+ | --totals[=SIGNAL] | ||
+ | with an argument - print total bytes when this | ||
+ | | ||
+ | | ||
+ | | ||
+ | --utc print file modification times in UTC | ||
+ | -v, --verbose | ||
+ | --warning=KEYWORD | ||
+ | -w, --interactive, | ||
+ | ask for confirmation for every action | ||
+ | |||
+ | | ||
+ | |||
+ | -o when creating, same as --old-archive; | ||
+ | | ||
+ | |||
+ | Other options: | ||
+ | |||
+ | -?, --help | ||
+ | --restrict | ||
+ | --usage | ||
+ | --version | ||
+ | |||
+ | Mandatory or optional arguments to long options are also mandatory or optional | ||
+ | for any corresponding short options. | ||
+ | |||
+ | The backup suffix is ' | ||
+ | The version control may be set with --backup or VERSION_CONTROL, | ||
+ | |||
+ | none, off never make backups | ||
+ | t, numbered | ||
+ | nil, existing | ||
+ | never, simple | ||
+ | |||
+ | Valid arguments for the --quoting-style option are: | ||
+ | |||
+ | literal | ||
+ | shell | ||
+ | shell-always | ||
+ | shell-escape | ||
+ | shell-escape-always | ||
+ | c | ||
+ | c-maybe | ||
+ | escape | ||
+ | locale | ||
+ | clocale | ||
+ | |||
+ | *This* tar defaults to: | ||
+ | --format=gnu -f- -b20 --quoting-style=escape --rmt-command=/ | ||
+ | --rsh-command=/ | ||
+ | </ | ||
+ | |||
+ | ===LAB #1 - Travailler avec la Commande tar=== | ||
+ | |||
+ | Vous allez maintenant sauvegarder votre dossier **test** ainsi que son contenu vers un fichier : | ||
+ | |||
+ | < | ||
+ | [root@centos8 repZ]# tar cvf / | ||
+ | tar: Removing leading `/' from member names | ||
+ | /test/ | ||
+ | /test/repY/ | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | /test/repZ/ | ||
+ | / | ||
+ | / | ||
+ | </ | ||
+ | |||
+ | Pour visualiser la **table of contents** de votre sauvegarde, utilisez la commande suivante : | ||
+ | |||
+ | < | ||
+ | [root@centos8 repZ]# tar tvf / | ||
+ | drwxr-xr-x root/ | ||
+ | drwxr-xr-x root/ | ||
+ | -rw-r--r-- root/ | ||
+ | -rw-r--r-- root/ | ||
+ | -rw-r--r-- root/ | ||
+ | drwxr-xr-x root/ | ||
+ | -rw-r--r-- root/ | ||
+ | -rw-r--r-- root/ | ||
+ | </ | ||
+ | |||
+ | Afin de créer une sauvegarde incrémentale, | ||
+ | |||
+ | < | ||
+ | [root@centos8 repZ]# touch / | ||
+ | </ | ||
+ | |||
+ | Modifiez maintenant deux des fichiers de votre arborescence **test** : | ||
+ | |||
+ | < | ||
+ | [root@centos8 repZ]# echo " | ||
+ | [root@centos8 repZ]# echo "RHEL is wonderful \!" > / | ||
+ | </ | ||
+ | |||
+ | Pour procéder à votre sauvegarde incrémentale, | ||
+ | |||
+ | Saisissez donc la commande suivante : | ||
+ | |||
+ | < | ||
+ | [root@centos8 repZ]# tar -cvf / | ||
+ | tar: Removing leading `/' from member names | ||
+ | /test/ | ||
+ | /test/repY/ | ||
+ | / | ||
+ | tar: / | ||
+ | tar: / | ||
+ | /test/repZ/ | ||
+ | / | ||
+ | tar: / | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important 60%> | ||
+ | **Important** - Notez l' | ||
+ | </ | ||
+ | |||
+ | Contrôlez maintenant le contenu de l' | ||
+ | |||
+ | < | ||
+ | [root@centos8 repZ]# tar tvf / | ||
+ | drwxr-xr-x root/ | ||
+ | drwxr-xr-x root/ | ||
+ | -rw-r--r-- root/ | ||
+ | drwxr-xr-x root/ | ||
+ | -rw-r--r-- root/ | ||
+ | </ | ||
+ | |||
+ | Supprimez maintenant le contenu du répertoire **test** : | ||
+ | |||
+ | < | ||
+ | [root@centos8 repZ]# rm -rf /test/* | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important 60%> | ||
+ | **Important** - Notez que le système vous permet de supprimer le répertoire **/ | ||
+ | </ | ||
+ | |||
+ | Afin de pouvoir restaurer les fichiers de votre première sauvegarde, placez-vous à la racine de votre système et restaurez le contenu de votre répertoire **test** en saisissant la commande tar suivante : | ||
+ | |||
+ | < | ||
+ | [root@centos8 repZ]# cd / | ||
+ | [root@centos8 /]# tar xvf / | ||
+ | test/ | ||
+ | test/repY/ | ||
+ | test/ | ||
+ | test/ | ||
+ | test/ | ||
+ | test/repZ/ | ||
+ | test/ | ||
+ | test/ | ||
+ | </ | ||
+ | |||
+ | Constatez maintenant que l' | ||
+ | |||
+ | < | ||
+ | [root@centos8 /]# ls -lR /test | ||
+ | /test: | ||
+ | total 0 | ||
+ | drwxr-xr-x. 2 root root 36 Jun 2 14:05 repY | ||
+ | drwxr-xr-x. 2 root root 26 Jun 2 14:05 repZ | ||
+ | |||
+ | /test/repY: | ||
+ | total 0 | ||
+ | -rw-r--r--. 1 root root 0 Jun 2 14:05 Y1 | ||
+ | -rw-r--r--. 1 root root 0 Jun 2 14:05 Y2 | ||
+ | -rw-r--r--. 1 root root 0 Jun 2 14:05 Y3 | ||
+ | |||
+ | /test/repZ: | ||
+ | total 0 | ||
+ | -rw-r--r--. 1 root root 0 Jun 2 14:05 Z1 | ||
+ | -rw-r--r--. 1 root root 0 Jun 2 14:05 Z2 | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important 60%> | ||
+ | **Important** - Notez qu'à ce stade les fichiers **/ | ||
+ | </ | ||
+ | |||
+ | Restaurez maintenant votre archive incrémentale : | ||
+ | |||
+ | < | ||
+ | [root@centos8 /]# tar xvf / | ||
+ | test/ | ||
+ | test/repY/ | ||
+ | test/ | ||
+ | test/repZ/ | ||
+ | test/ | ||
+ | </ | ||
+ | |||
+ | Constatez maintenant que l' | ||
+ | |||
+ | < | ||
+ | [root@centos8 /]# ls -lR /test | ||
+ | /test: | ||
+ | total 0 | ||
+ | drwxr-xr-x. 2 root root 36 Jun 2 14:05 repY | ||
+ | drwxr-xr-x. 2 root root 26 Jun 2 14:05 repZ | ||
+ | |||
+ | /test/repY: | ||
+ | total 4 | ||
+ | -rw-r--r--. 1 root root 20 Jun 2 14:08 Y1 | ||
+ | -rw-r--r--. 1 root root 0 Jun 2 14:05 Y2 | ||
+ | -rw-r--r--. 1 root root 0 Jun 2 14:05 Y3 | ||
+ | |||
+ | /test/repZ: | ||
+ | total 4 | ||
+ | -rw-r--r--. 1 root root 21 Jun 2 14:09 Z1 | ||
+ | -rw-r--r--. 1 root root 0 Jun 2 14:05 Z2 | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important 60%> | ||
+ | **Important** - Notez que les fichiers **/ | ||
+ | </ | ||
+ | |||
+ | ===La Commande GPL tar et la Compression=== | ||
+ | |||
+ | Dernièrement, | ||
+ | |||
+ | ^ Algorythme ^ Option de la commande tar ^ | ||
+ | | gzip | z | | ||
+ | | bzip2 | j | | ||
+ | | lzma | J | | ||
+ | |||
+ | ====La Commande cpio==== | ||
+ | |||
+ | ===Présentation=== | ||
+ | |||
+ | La commande **cpio** (Copy Input To Output). cpio peut gérer les archives au format **tar**. La différence majeure entre tar et cpio est que ce dernier stocke les chemins d' | ||
+ | |||
+ | Vous allez utiliser maintenant le logiciel **cpio** pour effectuer les sauvegardes et restaurations. | ||
+ | |||
+ | ===Options de la Commande=== | ||
+ | |||
+ | Les options de la commande **cpio** sont : | ||
+ | |||
+ | < | ||
+ | [root@centos8 /]# cpio --help | ||
+ | Usage: cpio [OPTION...] [destination-directory] | ||
+ | GNU `cpio' copies files to and from archives | ||
+ | |||
+ | Examples: | ||
+ | # Copy files named in name-list to the archive | ||
+ | cpio -o < name-list [> archive] | ||
+ | # Extract files from the archive | ||
+ | cpio -i [< archive] | ||
+ | # Copy files named in name-list to destination-directory | ||
+ | cpio -p destination-directory < name-list | ||
+ | |||
+ | Main operation mode: | ||
+ | -i, --extract | ||
+ | mode) | ||
+ | -o, --create | ||
+ | -p, --pass-through | ||
+ | -t, --list | ||
+ | |||
+ | | ||
+ | |||
+ | --block-size=BLOCK-SIZE | ||
+ | bytes | ||
+ | -B Set the I/O block size to 5120 bytes | ||
+ | -c | ||
+ | | ||
+ | | ||
+ | -C, --io-size=NUMBER | ||
+ | bytes | ||
+ | -D, --directory=DIR | ||
+ | --force-local | ||
+ | | ||
+ | -H, --format=FORMAT | ||
+ | --quiet | ||
+ | -R, --owner=[USER][: | ||
+ | | ||
+ | -v, --verbose | ||
+ | -V, --dot Print a " | ||
+ | -W, --warning=FLAG | ||
+ | ' | ||
+ | | ||
+ | |||
+ | | ||
+ | |||
+ | -F, --file=[[USER@]HOST: | ||
+ | Use this FILE-NAME instead of standard input or | ||
+ | | ||
+ | and host names in case of a remote archive | ||
+ | -M, --message=STRING | ||
+ | | ||
+ | --rsh-command=COMMAND | ||
+ | |||
+ | | ||
+ | |||
+ | -b, --swap | ||
+ | | ||
+ | -f, --nonmatching | ||
+ | | ||
+ | -I [[USER@]HOST: | ||
+ | | ||
+ | names in case of a remote archive | ||
+ | -n, --numeric-uid-gid | ||
+ | | ||
+ | -r, --rename | ||
+ | -s, --swap-bytes | ||
+ | -S, --swap-halfwords | ||
+ | files | ||
+ | --to-stdout | ||
+ | |||
+ | -E, --pattern-file=FILE | ||
+ | | ||
+ | --only-verify-crc | ||
+ | | ||
+ | | ||
+ | |||
+ | | ||
+ | |||
+ | -A, --append | ||
+ | --device-independent, | ||
+ | | ||
+ | --ignore-devno | ||
+ | -O [[USER@]HOST: | ||
+ | | ||
+ | and host names in case of a remote archive | ||
+ | --renumber-inodes | ||
+ | |||
+ | | ||
+ | |||
+ | -l, --link | ||
+ | | ||
+ | |||
+ | | ||
+ | |||
+ | --absolute-filenames | ||
+ | the file names | ||
+ | --no-absolute-filenames | ||
+ | | ||
+ | |||
+ | | ||
+ | |||
+ | -0, --null | ||
+ | | ||
+ | -a, --reset-access-time | ||
+ | them | ||
+ | -L, --dereference | ||
+ | that they point to instead of copying the links). | ||
+ | |||
+ | | ||
+ | |||
+ | -d, --make-directories | ||
+ | -m, --preserve-modification-time | ||
+ | | ||
+ | | ||
+ | --no-preserve-owner | ||
+ | --sparse | ||
+ | files | ||
+ | -u, --unconditional | ||
+ | |||
+ | -?, --help | ||
+ | --usage | ||
+ | --version | ||
+ | |||
+ | Mandatory or optional arguments to long options are also mandatory or optional | ||
+ | for any corresponding short options. | ||
+ | |||
+ | Report bugs to < | ||
+ | </ | ||
+ | |||
+ | ===LAB #2 - Travailler avec la Commande cpio=== | ||
+ | |||
+ | Dans un premier temps, vous devez utiliser la commande **find** pour construire une liste de fichiers à sauvegarder : | ||
+ | |||
+ | < | ||
+ | [root@centos8 /]# find /test > / | ||
+ | [root@centos8 /]# cat / | ||
+ | /test | ||
+ | /test/repY | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | /test/repZ | ||
+ | / | ||
+ | / | ||
+ | </ | ||
+ | |||
+ | Sauvegardez maintenant les fichiers et répertoires référencés par le fichier **/ | ||
+ | |||
+ | < | ||
+ | [root@centos8 /]# cpio -ov < / | ||
+ | /test | ||
+ | /test/repY | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | /test/repZ | ||
+ | / | ||
+ | / | ||
+ | 1 block | ||
+ | </ | ||
+ | |||
+ | Consultez maintenant la **table of contents** de votre sauvegarde : | ||
+ | |||
+ | < | ||
+ | [root@centos8 /]# cpio -it < / | ||
+ | /test | ||
+ | /test/repY | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | /test/repZ | ||
+ | / | ||
+ | / | ||
+ | 1 block | ||
+ | </ | ||
+ | |||
+ | Supprimez maintenant le répertoire **/ | ||
+ | |||
+ | < | ||
+ | [root@centos8 /]# rm -rf /test/repY | ||
+ | </ | ||
+ | |||
+ | Contrôlez le bon déroulement de la suppression : | ||
+ | |||
+ | < | ||
+ | [root@centos8 /]# ls -lR /test | ||
+ | /test: | ||
+ | total 0 | ||
+ | drwxr-xr-x. 2 root root 26 Jun 2 14:05 repZ | ||
+ | |||
+ | /test/repZ: | ||
+ | total 4 | ||
+ | -rw-r--r--. 1 root root 21 Jun 2 14:09 Z1 | ||
+ | -rw-r--r--. 1 root root 0 Jun 2 14:05 Z2 | ||
+ | </ | ||
+ | |||
+ | Restaurez les fichiers supprimés : | ||
+ | |||
+ | < | ||
+ | [root@centos8 /]# cpio -ivdum "/ | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | 1 block | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important 60%> | ||
+ | **Important** - Notez l' | ||
+ | </ | ||
+ | |||
+ | Contrôlez le bon déroulement de la restauration : | ||
+ | |||
+ | < | ||
+ | [root@centos8 /]# ls -lR /test | ||
+ | /test: | ||
+ | total 0 | ||
+ | drwxr-xr-x. 2 root root 36 Jun 2 14:17 repY | ||
+ | drwxr-xr-x. 2 root root 26 Jun 2 14:05 repZ | ||
+ | |||
+ | /test/repY: | ||
+ | total 4 | ||
+ | -rw-r--r--. 1 root root 20 Jun 2 14:08 Y1 | ||
+ | -rw-r--r--. 1 root root 0 Jun 2 14:05 Y2 | ||
+ | -rw-r--r--. 1 root root 0 Jun 2 14:05 Y3 | ||
+ | |||
+ | /test/repZ: | ||
+ | total 4 | ||
+ | -rw-r--r--. 1 root root 21 Jun 2 14:09 Z1 | ||
+ | -rw-r--r--. 1 root root 0 Jun 2 14:05 Z2 | ||
+ | </ | ||
+ | |||
+ | ====La Commande dd==== | ||
+ | |||
+ | ===Présentation=== | ||
+ | |||
+ | La commande **dd** n'est pas réellement une commande de sauvegarde. | ||
+ | |||
+ | La commande **dd** copie le fichier passé en entrée dans le fichier de sortie en limitant le nombre d' | ||
+ | |||
+ | * **count** | ||
+ | * le nombre | ||
+ | * **bs** | ||
+ | * la taille du bloc à copier | ||
+ | |||
+ | ===Options de la Commande=== | ||
+ | |||
+ | Les options de la commande **dd** sont : | ||
+ | |||
+ | < | ||
+ | [root@centos8 /]# dd --help | ||
+ | Usage: dd [OPERAND]... | ||
+ | or: dd OPTION | ||
+ | Copy a file, converting and formatting according to the operands. | ||
+ | |||
+ | bs=BYTES | ||
+ | overrides ibs and obs | ||
+ | cbs=BYTES | ||
+ | conv=CONVS | ||
+ | count=N | ||
+ | ibs=BYTES | ||
+ | if=FILE | ||
+ | iflag=FLAGS | ||
+ | obs=BYTES | ||
+ | of=FILE | ||
+ | oflag=FLAGS | ||
+ | seek=N | ||
+ | skip=N | ||
+ | status=LEVEL | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | N and BYTES may be followed by the following multiplicative suffixes: | ||
+ | c =1, w =2, b =512, kB =1000, K =1024, MB =1000*1000, M =1024*1024, xM =M, | ||
+ | GB =1000*1000*1000, | ||
+ | |||
+ | Each CONV symbol may be: | ||
+ | |||
+ | ascii from EBCDIC to ASCII | ||
+ | ebcdic | ||
+ | ibm from ASCII to alternate EBCDIC | ||
+ | block pad newline-terminated records with spaces to cbs-size | ||
+ | unblock | ||
+ | lcase | ||
+ | ucase | ||
+ | sparse | ||
+ | swab swap every pair of input bytes | ||
+ | sync pad every input block with NULs to ibs-size; when used | ||
+ | with block or unblock, pad with spaces rather than NULs | ||
+ | excl fail if the output file already exists | ||
+ | nocreat | ||
+ | notrunc | ||
+ | noerror | ||
+ | fdatasync | ||
+ | fsync | ||
+ | |||
+ | Each FLAG symbol may be: | ||
+ | |||
+ | append | ||
+ | direct | ||
+ | directory | ||
+ | dsync use synchronized I/O for data | ||
+ | sync likewise, but also for metadata | ||
+ | fullblock | ||
+ | nonblock | ||
+ | noatime | ||
+ | nocache | ||
+ | noctty | ||
+ | nofollow | ||
+ | count_bytes | ||
+ | skip_bytes | ||
+ | seek_bytes | ||
+ | |||
+ | Sending a USR1 signal to a running ' | ||
+ | print I/O statistics to standard error and then resume copying. | ||
+ | |||
+ | Options are: | ||
+ | |||
+ | --help | ||
+ | --version | ||
+ | |||
+ | GNU coreutils online help: < | ||
+ | Full documentation at: < | ||
+ | or available locally via: info ' | ||
+ | </ | ||
+ | |||
+ | ===LAB #3 - Travailler avec la Commande dd=== | ||
+ | |||
+ | Vous allez utiliser maintenant le logiciel **dd** pour effectuer une sauvegarde de votre MBR et de la table des partitions. | ||
+ | |||
+ | Effectuez une sauvegarde de votre MBR qui se trouve dans les premiers 446 octets de votre disque **/ | ||
+ | |||
+ | < | ||
+ | [root@centos8 /]# dd if=/dev/sda of=/ | ||
+ | 446+0 records in | ||
+ | 446+0 records out | ||
+ | 446 bytes copied, 0.00202127 s, 221 kB/s | ||
+ | </ | ||
+ | |||
+ | Effectuez maintenant une sauvegarde de votre table des partitions qui se trouve dans les 64 octets après les 446 précédemment sauvegardés : | ||
+ | |||
+ | < | ||
+ | [root@centos8 /]# dd if=/dev/sda of=/ | ||
+ | 64+0 records in | ||
+ | 64+0 records out | ||
+ | 64 bytes copied, 0.000409593 s, 156 kB/s | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important 60%> | ||
+ | **Important** - Notez l' | ||
+ | </ | ||
+ | |||
+ | ====Les Commandes dump et restore==== | ||
+ | |||
+ | ===Présentation=== | ||
+ | |||
+ | Les commandes **dump** et **restore** se basent sur le format d' | ||
+ | |||
+ | Il est important de noter que le système de fichier ne doit pas être utilisé pendant le processus de dump. Pour cette raison il est normalement conseillé de démonter le système de fichiers. | ||
+ | |||
+ | Il existe 10 niveaux de dump possibles de **0** à **9**. Lors d'un dump le niveau est spécifié. Chaque fois qu'un dump est effectué, cette information est sauvegardée dans le fichier / | ||
+ | |||
+ | Par définition un dump de niveau **0** est une sauvegarde complète tandis que le dump de niveau 1 est une sauvegarde incrémentale. | ||
+ | |||
+ | Notez que les fichiers sont sauvegardés avec des nom relatifs. Ceci implique que vous devez vous positionner dans le système de fichiers lors de la restauration avec la commande **restore**. | ||
+ | |||
+ | ----- | ||
+ | Copyright © 2023 Hugh Norris. |