Hah, isso é muito fácil:
-
crie um diretório
/sysbackup
:mkdir /sysbackup
-
copie o seguinte script em um editor:
#!/bin/bash # # This script saves the well-known (last good) partition table entries to a text file # and the MBR to a binary file for all live disks on the system. # # Copyright (c) Fabby 2017 # # This program is free software: you can redistribute it and/or modify it under # the terms of the GNU General Public License as published by the Free Software # Foundation, either version 3 of the License, or (at your option) any later # version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY # or FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, # DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR # THE USE OR OTHER DEALINGS IN THE SOFTWARE. # See the GNU General Public License for more details. # # You DID NOT receive a copy of the GNU General Public License along with # this program as the license is bigger then this program. # Therefore, see http://www.gnu.org/licenses/ for more details. # # This script should be run at the /etc/rc.local or systemd equivalent point in time # for szDisk in /dev/?d?; do sfdisk --dump "$szDisk" > /sysbackup/PartBackup-"$(hostname)-${szDisk//\//-}""$(date +"%F-%H%M%S%N")"".txt" dd if="$szDisk" of=/sysbackup/MBRBackup-"$(hostname)-${szDisk//\//-}""$(date +"%F-%H%M%S%N")"".bck" bs=512 count=1 done;
-
salve em
/usr/local/bin
(Por exemplo, comombr-pt-bck
) -
chmod +x /usr/local/bin/mbr-pt-bck
- executá-lo usando
sudo mbr-pt-bck
- Certifique-se de que
/sysbackup/
esteja incluído no comandorsync
(ou comparável).
Alternativamente,
- coloque o script acima em
/etc/rc.local
ou equivalente systemd e execute-o automaticamente a cada inicialização. - inclua-o no seu script de pré-backup