issue124:tutoriel1
Différences
Ci-dessous, les différences entre deux révisions de la page.
Prochaine révision | Révision précédente | ||
issue124:tutoriel1 [2017/08/28 12:26] – créée auntiee | issue124:tutoriel1 [2017/09/11 16:51] (Version actuelle) – andre_domenech | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
- | Backups are fundamental aspects of the IT life: for personal purposes as well as in professional environments. Ranging from personal documents to server configurations and databases, sometimes a backup is life-saving. There is plenty of documentation around the web: documents about backup strategies, how-tos, backup softwares, and so on. | + | ===== 1 ===== |
+ | |||
+ | **Backups are fundamental aspects of the IT life: for personal purposes as well as in professional environments. Ranging from personal documents to server configurations and databases, sometimes a backup is life-saving. There is plenty of documentation around the web: documents about backup strategies, how-tos, backup softwares, and so on. | ||
The big drawback of backups is, most of the time, space occupancy. A good software, or a good strategy, can mitigate this by mean of incremental backups. But in some cases, learning and implementing a specialized backup software is laborious, tedious, and the learning curve is too high especially when we only need “a simple” copy of the last useful files or database dump. In any case, there isn’t a self-configuring software out there: strategies and policies are up to the system administrator or backup administrator. And last but not least, what about restore? We all hope not to need to restore a backup, but sometimes disasters can occur: from deletion of an important document to database server crash. | The big drawback of backups is, most of the time, space occupancy. A good software, or a good strategy, can mitigate this by mean of incremental backups. But in some cases, learning and implementing a specialized backup software is laborious, tedious, and the learning curve is too high especially when we only need “a simple” copy of the last useful files or database dump. In any case, there isn’t a self-configuring software out there: strategies and policies are up to the system administrator or backup administrator. And last but not least, what about restore? We all hope not to need to restore a backup, but sometimes disasters can occur: from deletion of an important document to database server crash. | ||
- | Here, in this article, we will talk about a sort of incremental backup. How difficult is it to retrieve a backup or restore a database from an incremental backup? In a company, sometimes, the System Administrator is also the DBA and even the Backup Administrator at the same time, so testing backups’ restoration is, most times, a zero priority task. | + | Here, in this article, we will talk about a sort of incremental backup. How difficult is it to retrieve a backup or restore a database from an incremental backup? In a company, sometimes, the System Administrator is also the DBA and even the Backup Administrator at the same time, so testing backups’ restoration is, most times, a zero priority task.** |
+ | |||
+ | Les sauvegardes sont des aspects fondamentaux de la vie informatique, | ||
+ | |||
+ | La plupart du temps, le gros inconvénient des sauvegardes est l' | ||
+ | |||
+ | Dans cet article, nous parlerons d'un type de sauvegarde incrémentielle. À quel point est-il difficile de récupérer une sauvegarde ou de restaurer une base de données à partir d'une sauvegarde incrémentielle ? Parfois, dans une entreprise, l' | ||
- | As said before, space occupancy (hard disk or tapes) is a big question to address. | + | **As said before, space occupancy (hard disk or tapes) is a big question to address. |
Let’s talk about a disk shared between many users, or the home directories of such users. Let’s say we want to use an affordable and simple solution using well known tools, that must be a reliable solution as well. The choice of the tool, if we work on Linux and Unix, will usually fall on rsync. | Let’s talk about a disk shared between many users, or the home directories of such users. Let’s say we want to use an affordable and simple solution using well known tools, that must be a reliable solution as well. The choice of the tool, if we work on Linux and Unix, will usually fall on rsync. | ||
Ligne 12: | Ligne 20: | ||
So, if we use rsync, we must take care of such things: we must avoid garbage and we cannot rely only on one backup, that is the last time rsync has run. So, usually, we end up writing a complex script, or we spend time looking for and testing some script or software found on the Internet, falling again in a pointless learning curve or using a script that doesn’t fit our needs. | So, if we use rsync, we must take care of such things: we must avoid garbage and we cannot rely only on one backup, that is the last time rsync has run. So, usually, we end up writing a complex script, or we spend time looking for and testing some script or software found on the Internet, falling again in a pointless learning curve or using a script that doesn’t fit our needs. | ||
- | Well, a filesystem snapshot can save our bacon. In this article we will talk about ZFS snapshot feature. | + | Well, a filesystem snapshot can save our bacon. In this article we will talk about ZFS snapshot feature.** |
- | What is ZFS | + | Comme déjà indiqué, l' |
+ | |||
+ | Parlons d'un disque partagé par beaucoup d' | ||
+ | |||
+ | Il faut tenir compte du fait que rsync ne supprime pas les fichiers sur la destination qui ne sont plus dans le fichier source ; mais nous ne pouvons pas stocker des fichiers indéfiniment, | ||
+ | |||
+ | Ainsi, si nous utilisons rsync, nous devons nous préoccuper de telles choses : nous devons éviter les déchets et nous ne devons pas nous fier à une seule sauvegarde, c' | ||
+ | |||
+ | En fait, un instantané de notre système de fichiers peut nous tirer du pétrin. Dans cet article, nous parlerons de la fonctionnalité instantanée de ZFS. | ||
+ | |||
+ | ===== 2 ===== | ||
+ | |||
+ | **What is ZFS | ||
ZFS is a robust, enterprise grade, filesystem and volume manager developed by Sun in the late 2001; today it is the default file system on Solaris and a bunch of Operating Systems based on the Open Source Illumos kernel, like SmartOS, Openindiana, | ZFS is a robust, enterprise grade, filesystem and volume manager developed by Sun in the late 2001; today it is the default file system on Solaris and a bunch of Operating Systems based on the Open Source Illumos kernel, like SmartOS, Openindiana, | ||
Ligne 20: | Ligne 40: | ||
I don’t want to go deep into the advantages, the technical characteristics or the options of ZFS, but I want just to underline the ease-of-use of some features that this file system provides, like, exactly, snapshots. | I don’t want to go deep into the advantages, the technical characteristics or the options of ZFS, but I want just to underline the ease-of-use of some features that this file system provides, like, exactly, snapshots. | ||
- | Well, also other filesystems like BtrFS, or Logical Volume managers (LVM) have snapshot functionalities as well; even Windows has something like that, called Shadow Copy, but ZFS, as far as I know, is the most simple and proficient to use. | + | Well, also other filesystems like BtrFS, or Logical Volume managers (LVM) have snapshot functionalities as well; even Windows has something like that, called Shadow Copy, but ZFS, as far as I know, is the most simple and proficient to use.** |
+ | |||
+ | ZFS | ||
+ | |||
+ | ZFS est un gestionnaire de volume et de système de fichiers robuste et de niveau professionnel développé par Sun, fin 2001. De nos jours, il s'agit du système de fichiers par défaut sur Solaris et pas mal d' | ||
+ | |||
+ | Je ne veux pas détailler les avantages, les caractéristiques techniques ou les options de ZFS, mais tout simplement mettre l' | ||
+ | |||
+ | En fait, d' | ||
+ | |||
+ | ===== 3 ===== | ||
- | How to create a zpool | + | **How to create a zpool |
This is only a quick example. Also, in this case I don’t want to dig deep into technical details. | This is only a quick example. Also, in this case I don’t want to dig deep into technical details. | ||
Ligne 38: | Ligne 68: | ||
sudo zpool create tank /dev/sdb | sudo zpool create tank /dev/sdb | ||
- | Please look at this link, in order to understand why using sdb, instead of the disk UUID, might not be a good thing http:// | + | Please look at this link, in order to understand why using sdb, instead of the disk UUID, might not be a good thing http:// |
- | Let’s create a ZFS filesystem inside the zpool | + | Créer un zpool |
+ | |||
+ | Ceci n'est qu'un exemple rapide. Et aussi, ici, je ne veux pas me pencher sur beaucoup de détails techniques. | ||
+ | |||
+ | Bon, installons le côté ZFS. | ||
+ | |||
+ | sudo apt-get install zfsutils-linux | ||
+ | |||
+ | Branchez une clé USB et utilisez fdisk pour créer une nouvelle table GPT vide de partitions | ||
+ | |||
+ | sudo fdisk /dev/sdb | ||
+ | |||
+ | Quittez fdisk et créons le zpool (pensez-y comme une sorte de volume). « Tank » est le nom de mon zpool, mais vous pouvez choisir le nom qui vous chante. | ||
+ | |||
+ | sudo zpool create tank /dev/sdb | ||
+ | |||
+ | Veuillez regarder ce lien afin de comprendre pourquoi l' | ||
+ | |||
+ | ===== 4 ===== | ||
+ | |||
+ | **Let’s create a ZFS filesystem inside the zpool | ||
sudo zfs create tank/ | sudo zfs create tank/ | ||
Ligne 56: | Ligne 106: | ||
So in our case the command could be: | So in our case the command could be: | ||
+ | sudo zfs snapshot tank/ | ||
+ | |||
+ | Créons un système de fichiers ZFS dans le zpool : | ||
+ | |||
+ | sudo zfs create tank/ | ||
+ | |||
+ | Activez la compression à la volée (on-the-fly). Oui, c'est une autre fonctionnalité de ZFS. Il y a un bon équilibre entre la performance et le niveau de compression dans l' | ||
+ | |||
+ | sudo zfs set compression=lz4 tank/ | ||
+ | |||
+ | Faisons le premier instantané (snapshot) | ||
+ | |||
+ | Un instantané est l' | ||
+ | |||
+ | zfs snapshot filesystem@name | ||
+ | |||
+ | Ainsi, dans notre cas, la commande pourrait être : | ||
sudo zfs snapshot tank/ | sudo zfs snapshot tank/ | ||
- | Since it doesn’t consist of an incremental copy of files, like Mac OS X Time Machine, but it is done at block level, the snapshot operation is immediate. | + | ===== 5 ===== |
+ | |||
+ | **Since it doesn’t consist of an incremental copy of files, like Mac OS X Time Machine, but it is done at block level, the snapshot operation is immediate. | ||
Initially, the disk space occupied by a snapshot is zero, since the snapshot corresponds exactly to the original file system. As the files on the file system change (new files, deleted ones, updated files), disk space becomes unique to the snapshot, so the space used by the snapshot is strictly related to changes, writes, and deletes, performed on the file system. | Initially, the disk space occupied by a snapshot is zero, since the snapshot corresponds exactly to the original file system. As the files on the file system change (new files, deleted ones, updated files), disk space becomes unique to the snapshot, so the space used by the snapshot is strictly related to changes, writes, and deletes, performed on the file system. | ||
Ligne 66: | Ligne 135: | ||
Displaying and Accessing ZFS Snapshots | Displaying and Accessing ZFS Snapshots | ||
- | Now you can access data “backed up” in the snapshot in two ways: rolling back the snapshot (overwriting the working file system, read this as a complete restore), or accessing it to recover single files or directories. | + | Now you can access data “backed up” in the snapshot in two ways: rolling back the snapshot (overwriting the working file system, read this as a complete restore), or accessing it to recover single files or directories.** |
- | Rolling back the snapshot is as simple as taking it: | + | Puisqu' |
+ | |||
+ | Au départ, l' | ||
+ | |||
+ | Enfin, l' | ||
+ | |||
+ | Afficher et accéder aux instantanés ZFS | ||
+ | |||
+ | Vous pouvez accéder aux données « sauvegardées » dans l' | ||
+ | |||
+ | ===== 6 ===== | ||
+ | |||
+ | **Rolling back the snapshot is as simple as taking it: | ||
zfs rollback filesystem@name | zfs rollback filesystem@name | ||
Ligne 79: | Ligne 160: | ||
Here you can find all your snapshots, you will see a directory for every taken snapshot, and you can use usual commands (cp, rsync, scp, etc) to copy a previous file version wherever you need: you can replace or restore a file or a directory directly in the working file system. | Here you can find all your snapshots, you will see a directory for every taken snapshot, and you can use usual commands (cp, rsync, scp, etc) to copy a previous file version wherever you need: you can replace or restore a file or a directory directly in the working file system. | ||
- | That said, the backup policy can be the following: take a snapshot just before the rsync command and you are on your way. So you should not worry about previous versions of backups, incremental backups, huge used space, and so on. | + | That said, the backup policy can be the following: take a snapshot just before the rsync command and you are on your way. So you should not worry about previous versions of backups, incremental backups, huge used space, and so on.** |
- | To delete a snapshot, the command is as simple as | + | Faire une récupération complète est aussi simple que prendre un instantané : |
+ | |||
+ | zfs rollback filesystem@name | ||
+ | |||
+ | Mais faites attention : comme indiqué, faire une récupération écrasera le système de fichiers qui fonctionne ! Ainsi, une façon plus commode de récupérer des fichiers est d' | ||
+ | |||
+ | cd / | ||
+ | |||
+ | C'est ici que vous trouverez tous vos instantanés : chaque instantané aura son propre répertoire et vous pouvez utiliser les commandes habituelles (cp, rsync, scp, etc.) pour copier une version précédente d'un fichier où vous voudrez : vous pouvez remplacer ou restaurer un fichier ou un dossier directement dans le système de fichiers actif. | ||
+ | |||
+ | Cela étant dit, la politique de sauvegarde peut être la suivante : faire un instantané juste avant de lancer la commande rsync et vous voilà parti ! Ainsi, vous n'avez pas à vous inquiéter des versions précédentes de sauvegardes, | ||
+ | |||
+ | ===== 7 ===== | ||
+ | |||
+ | **To delete a snapshot, the command is as simple as | ||
zfs destroy filesystem@name | zfs destroy filesystem@name | ||
Ligne 94: | Ligne 189: | ||
You can find the script here | You can find the script here | ||
- | https:// | + | https:// |
+ | Pour supprimer un instantané, | ||
+ | |||
+ | zfs destroy filesystem@name | ||
+ | |||
+ | Ce qui, dans notre exemple, serait | ||
+ | |||
+ | sudo zfs destroy tank/ | ||
+ | |||
+ | Exemple de script de sauvegarde | ||
+ | |||
+ | Voici l' | ||
+ | |||
+ | Le script se trouve ici : | ||
+ | https:// |
issue124/tutoriel1.1503915967.txt.gz · Dernière modification : 2017/08/28 12:26 de auntiee