# Restaurer une partition selon un historique

**URL:** <https://www.debian-fr.org/t/restaurer-une-partition-selon-un-historique/61550>\
**Category:** Pause Café\
**Created:** [Février 21, 2016, 8:00 UTC](https://www.debian-fr.org/t/restaurer-une-partition-selon-un-historique/61550 "2016-02-21T20:00:38Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![debianhadic](https://www.debian-fr.org/user_avatar/www.debian-fr.org/debianhadic/32/3870_2.png) [@debianhadic](https://www.debian-fr.org/u/debianhadic)\
**Post date:** [Février 21, 2016, 8:00 UTC](https://www.debian-fr.org/t/restaurer-une-partition-selon-un-historique/61550/1 "2016-02-21T20:00:38Z")

</div>

Sous Windows certain connaissent peut-être les “points de restauration”, le principe est simple, à un instant T le système “sauvegarde” l’état du filesystem, et on peut à tout moment revenir sur celui-ci à posteriori.  
ça fonctionne moyennement … De plus le fait de devoir au préalable penser à faire un point de restauration est pour moi dommageable; je recherche une solution (peut importe l’espace disque utilisé, ou le nombre de disques durs qu’il faudrait) qui permettrait de revenir à tout moment à une position antérieure d’au moins une semaine par exemple.  
Existe-t’il des projets qui font ça ?

---

<div class="post-metadata">

**Author:** ![fran.b](https://www.debian-fr.org/letter_avatar_proxy/v4/letter/f/d78d45/32.png) [@fran.b](https://www.debian-fr.org/u/fran.b)\
**Post date:** [Février 21, 2016, 8:00 UTC](https://www.debian-fr.org/t/restaurer-une-partition-selon-un-historique/61550/2 "2016-02-21T20:00:38Z")

</div>

Je peux te donner une solution. J’utilise aufs via mon paquet aufsroot (voir [boisson.homeip.net/aufsroot.html](http://boisson.homeip.net/aufsroot.html) ) pour faire des tests y compris des tests de noyaux. Il serait très facile de faire la chose suivante:

Tu as un système  
-\> Répertoire Base en lecture seule état du système à un instant T  
-\> Pour chaque jour d’après tu as un répertoire Jour-date monté en lecture seule  
-\> Le dernier jour correspond à un répetoire Jour monté en lecture écriture.

Chaque fois que le jour change, Base plus le jour d’après est fusionné.

Le nombre de jour peut être paramétré.

Pour revenir à une situation antérieure, il suffit d’effacer les répertoires qui suivent.

Je me fais fort de te faire un système de ce type (il me faut une petite demi journée donc pas de suite de suite…), tu testerais?

---

<div class="post-metadata">

**Author:** ![MisterFreez](https://www.debian-fr.org/letter_avatar_proxy/v4/letter/m/bb73d2/32.png) [@MisterFreez](https://www.debian-fr.org/u/MisterFreez)\
**Post date:** [Février 21, 2016, 8:00 UTC](https://www.debian-fr.org/t/restaurer-une-partition-selon-un-historique/61550/3 "2016-02-21T20:00:39Z")

</div>

Ce ne serait pas plus simple avec des snapshot de partition (via lvm, sur zsf ou sur btrfs) ?

---

<div class="post-metadata">

**Author:** ![debianhadic](https://www.debian-fr.org/user_avatar/www.debian-fr.org/debianhadic/32/3870_2.png) [@debianhadic](https://www.debian-fr.org/u/debianhadic)\
**Post date:** [Février 21, 2016, 8:00 UTC](https://www.debian-fr.org/t/restaurer-une-partition-selon-un-historique/61550/4 "2016-02-21T20:00:39Z")

</div>

@Fran.b -\> Ton système, si je comprends bien te permet de restaurer à un jour antérieur, mais pas plus précisément une heure précise.  
@Misterfreez -\> Tu peux expliquer plus en détails ?

---

<div class="post-metadata">

**Author:** ![fran.b](https://www.debian-fr.org/letter_avatar_proxy/v4/letter/f/d78d45/32.png) [@fran.b](https://www.debian-fr.org/u/fran.b)\
**Post date:** [Février 21, 2016, 8:00 UTC](https://www.debian-fr.org/t/restaurer-une-partition-selon-un-historique/61550/5 "2016-02-21T20:00:39Z")

</div>

[quote=“debianhadic”]@Fran.b -\> Ton système, si je comprends bien te permet de restaurer à un jour antérieur, mais pas plus précisément une heure précise.[/quote]Oui.Pour être exact,pour que ça soit pratique, tu ne peux restaurer que sur la situation juste avant un redémarrage de la machine. Après, quels redémarrages sélectionner? Cela peut dépendre.

---

<div class="post-metadata">

**Author:** ![Clochette](https://www.debian-fr.org/user_avatar/www.debian-fr.org/clochette/32/8757_2.png) [@Clochette](https://www.debian-fr.org/u/Clochette)\
**Post date:** [Février 21, 2016, 8:00 UTC](https://www.debian-fr.org/t/restaurer-une-partition-selon-un-historique/61550/6 "2016-02-21T20:00:39Z")

</div>

[quote=“debianhadic”]  
@Misterfreez -\> Tu peux expliquer plus en détails ?[/quote]

Je pense aussi que l’utilisation de zfs et btrfs permettent de facilement restaurer un snapshot effectué manuellement ou via un script couplé à une tâche cron.

Lvm permet aussi de faire des instantanée et donc de pouvoir restaurer à un version antérieur.

---

<div class="post-metadata">

**Author:** ![debianhadic](https://www.debian-fr.org/user_avatar/www.debian-fr.org/debianhadic/32/3870_2.png) [@debianhadic](https://www.debian-fr.org/u/debianhadic)\
**Post date:** [Février 21, 2016, 8:00 UTC](https://www.debian-fr.org/t/restaurer-une-partition-selon-un-historique/61550/7 "2016-02-21T20:00:40Z")

</div>

Une explication ? Un how-to ? Même très théorique ?

En gros je veux remplacer une solution vieille comme Hérode développée en interne qui foire tous les quatre matins, par un truc sérieux et open-source

---

<div class="post-metadata">

**Author:** ![fran.b](https://www.debian-fr.org/letter_avatar_proxy/v4/letter/f/d78d45/32.png) [@fran.b](https://www.debian-fr.org/u/fran.b)\
**Post date:** [Février 21, 2016, 8:00 UTC](https://www.debian-fr.org/t/restaurer-une-partition-selon-un-historique/61550/8 "2016-02-21T20:00:40Z")

</div>

Allez, regarde ça, c’est pile poil ce que tu cherches…  
[teejeetech.in/p/timeshift.html](http://www.teejeetech.in/p/timeshift.html)

---

<div class="post-metadata">

**Author:** ![etxeberrizahar](https://www.debian-fr.org/letter_avatar_proxy/v4/letter/e/43a26b/32.png) [@etxeberrizahar](https://www.debian-fr.org/u/etxeberrizahar)\
**Post date:** [Février 21, 2016, 8:00 UTC](https://www.debian-fr.org/t/restaurer-une-partition-selon-un-historique/61550/9 "2016-02-21T20:00:40Z")

</div>

LVM  
[tldp.org/HOWTO/LVM-HOWTO/sna … ackup.html](http://www.tldp.org/HOWTO/LVM-HOWTO/snapshots_backup.html)

> [@](#):
>
> 13.4. Taking a Backup Using Snapshots
> 
> Following on from the previous example we now want to use the extra space in the «&nbsp;ops&nbsp;» volume group to make a database backup every evening. To ensure that the data that goes onto the tape is consistent we use an LVM snapshot logical volume.
> 
> A snapshot volume is a special type of volume that presents all the data that was in the volume at the time the snapshot was created. For a more detailed description, see Section 3.8, Snapshots. This means we can back up that volume without having to worry about data being changed while the backup is going on, and we don’t have to take the database volume offline while the backup is taking place.
> 
> Note
> 
> In LVM1, this type of volume was read-only, but LVM2 creates read/write snapshots by default.  
> 13.4.1. Create the snapshot volume
> 
> There is a little over 500 Megabytes of free space in the «&nbsp;ops&nbsp;» volume group, so we will use all of it to allocate space for the snapshot logical volume. A snapshot volume can be as large or a small as you like but it must be large enough to hold all the changes that are likely to happen to the original volume during the lifetime of the snapshot. So here, allowing 500 megabytes of changes to the database volume which should be plenty.
> 
> # lvcreate -L592M -s -n dbbackup /dev/ops/databases
> 
> lvcreate – WARNING: the snapshot must be disabled if it gets full  
> lvcreate – INFO: using default snapshot chunk size of 64 KB for «&nbsp;/dev/ops/dbbackup&nbsp;»  
> lvcreate – doing automatic backup of «&nbsp;ops&nbsp;»  
> lvcreate – logical volume «&nbsp;/dev/ops/dbbackup&nbsp;» successfully created
> 
> Warning Full snapshot are automatically disabled
> 
> If the snapshot logical volume becomes full it will be dropped (become unusable) so it is vitally important to allocate enough space. The amount of space necessary is dependent on the usage of the snapshot, so there is no set recipe to follow for this. If the snapshot size equals the origin size, it will never overflow.

La taille des instantanés devra être en rapport avec la quantité de changements prévus.  
Bien qu’instantanés pris à l’instant t, ils évoluent dynamiquement après la prise de l’instantané selon les changements qui affecteront l’original  
(suppressions, éditions, ajouts, créations … de fichiers)  
Achtung : L’original doit être toujours exploitable.  
Calculer la taille selon besoins.  
Un instantané trop petit saturé est un instantané foutu.  
Un instantané trop gros est de l’espace gaché.  
Voir

# lvs

pour voir le taux d’occupation.

Montage instantanés.

[quote]  
13.4.2. Mount the snapshot volume

We can now create a mount-point and mount the volume

# mkdir /mnt/ops/dbbackup

# mount /dev/ops/dbbackup /mnt/ops/dbbackup

mount: block device /dev/ops/dbbackup is write-protected, mounting read-only [/quote]

> [@](#):
>
> 13.4.3. Do the backup
> 
> I assume you will have a more sophisticated backup strategy than this!
> 
> [code]
> 
> # tar -cf /dev/rmt0 /mnt/ops/dbbackup
> 
> tar: Removing leading `/’ from member names[/code]

Personnellement je m’en dispenserais. Trop couteux en espace disque.  
Conserver les instantanés sur disque.Les effacer après roulement prévu.Voir aussi l’avertissement plus bas à propos de btrfs («a snapshot is not a backup») parce que, répétons le, sans l’original qui sert de base, le snapshot est inexploitable.

Effacer les instantanés.

[quote] 13.4.4. Remove the snapshot

When the backup has finished you can now unmount the volume and remove it from the system. You should remove snapshot volume when you have finished with them because they take a copy of all data written to the original volume and this can hurt performance.

[code]

# umount /mnt/ops/dbbackup

# lvremove /dev/ops/dbbackup

lvremove – do you really want to remove «&nbsp;/dev/ops/dbbackup&nbsp;»? [y/n]: y  
lvremove – doing automatic backup of volume group «&nbsp;ops&nbsp;»  
lvremove – logical volume «&nbsp;/dev/ops/dbbackup&nbsp;» successfully removed[/code][/quote]

Btrfs  
Créer instantané, monter instantané … les principes sont semblables.  
Monter l’instantané en son / root revient à renommer l’instantané.  
[btrfs.wiki.kernel.org/index.php … ot\_example](https://btrfs.wiki.kernel.org/index.php/FAQ#snapshot_example)

[quote]What is a snapshot?

A snapshot is a frozen image of all the files and directories of a subvolume. For example, if you have two files («&nbsp;a&nbsp;» and «&nbsp;b&nbsp;») in a subvolume, you take a snapshot and you delete «&nbsp;b&nbsp;», the file you just deleted is still available in the snapshot you took. The great thing about Btrfs snapshots is you can operate on any files or directories vs lvm when it is the whole logical volume.

Note that a snapshot is not a backup: Snapshots work by use of btrfs’s copy-on-write behaviour. A snapshot and the original it was taken from initially share all of the same data blocks. If that data is damaged in some way (cosmic rays, bad disk sector, accident with dd to the disk), then the snapshot and the original will both be damaged. Snapshots are useful to have local online «&nbsp;copies&nbsp;» of the filesystem that can be referred back to, or to implement a form of deduplication, or to fix the state of a filesystem for making a full backup without anything changing underneath it. They do not in themselves make your data any safer.  
snapshot example

Since backup from tape are a pain here is the thoughts of a lazy sysadm that create a home directory as a Btrfs file system for their users, lets try some fancy net attached storage ideas.

```
/home
    Then there could be a snaphot every 6 hours via cron
        /home_today_00,/home_today_06,/home_today_12,/home_today_18, 

```

The logic would look something like this for rolling 3 day rotation that would use cron @ midnight

```
rename /home_today_00, /home_backday_1
create a symbolic link for /home_backDay_00 that points to real dir of /home_backday_1
rename /home_today_06, /home_backDay_06 , Need to do this for all hours (06..18)
/home_backday_1,/home_backday_2,/home_backday_3
    delete the /home_backday_3
    rename /home_backday_2 to /home_backday_3 day
    rename /home_backday_1 to /home_backday_2 day [/quote]

```

---

<div class="post-metadata">

**Author:** ![debianhadic](https://www.debian-fr.org/user_avatar/www.debian-fr.org/debianhadic/32/3870_2.png) [@debianhadic](https://www.debian-fr.org/u/debianhadic)\
**Post date:** [Février 21, 2016, 8:00 UTC](https://www.debian-fr.org/t/restaurer-une-partition-selon-un-historique/61550/10 "2016-02-21T20:00:40Z")

</div>

Vous êtes super les gars, j’ai de la lecture 🙂  
Je vous tiens informé.

---

<div class="post-metadata">

**Author:** ![AnatomicJC](https://www.debian-fr.org/user_avatar/www.debian-fr.org/anatomicjc/32/3869_2.png) [@AnatomicJC](https://www.debian-fr.org/u/AnatomicJC)\
**Post date:** [Février 21, 2016, 8:00 UTC](https://www.debian-fr.org/t/restaurer-une-partition-selon-un-historique/61550/11 "2016-02-21T20:00:41Z")

</div>

Je plussoie les snapshots.

Mais il s’agit bien de faire des snapshots de machines linux ou windows ?

---

<div class="post-metadata">

**Author:** ![debianhadic](https://www.debian-fr.org/user_avatar/www.debian-fr.org/debianhadic/32/3870_2.png) [@debianhadic](https://www.debian-fr.org/u/debianhadic)\
**Post date:** [Février 21, 2016, 8:00 UTC](https://www.debian-fr.org/t/restaurer-une-partition-selon-un-historique/61550/12 "2016-02-21T20:00:41Z")

</div>

100% Linux
