Me gustaría saber cómo:
- hacer una copia de seguridad
- hacer una restauración
de todos los MBR y todos los PT de todos mis discos en un archivo para poder hacer una copia de seguridad fácilmente usando rsync o un programa comparable.
------------Respuesta------------
Ja, eso es bastante fácil:
crea un directorio /sysbackup:
mkdir /sysbackup
copia el siguiente script en un 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;
guárdalo en /usr/local/bin (por ejemplo, como mbr-pt-bck)
- chmod +x /usr/local/bin/mbr-pt-bck
- ejecútelo usando sudo mbr-pt-bck
- Asegúrese de que /sysbackup/ esté incluido en su comando rsync (o similar).
Como alternativa,
- puInstale el script anterior en /etc/rc.local o systemd equivalente y ejecútelo automáticamente en cada arranque.
- inclúyalo en su script previo a la copia de seguridad
-
-wjandrea
-
@Fabby - t¡gracias! He guardado el archivo de script sin extensión. ¿Pero cómo lo ejecuto? Escribí el nombre del script en la terminal (después de navegar al directorio correcto) pero todavía no se ejecuta
- BenKoshy
-
- Fabby
------------Respuesta------------
Restaurar cualquiera de los elementos anteriores también es bastante fácil:
MBR:
dd if=/sysbackup/MBRBackup-szHostName-dev-sda.bck of=/dev/sda bs=512 count=1
PT:
Primero en un gato /sysbackup/PartBackup-szHostName-dev-sda.txt
Disk label type: msdos
Minor Start End Type Filesystem Flags
1 0.031 8056.032 primary ext3
Entonces simplemente haz:
parted /dev/sda rescue
y obtendrás el mensaje de rescate separado, donde deberás completar los datos del gato anterior
Start? 0
End? 8056
Information: A ext3 primary partition was found at 0.031MB ->
8056.030MB. Do you want to add it to the partition table?
Yes/No/Cancel? y