Help Automating Backup of Drive
I need help with this problem. OK, here goes. I think I have a bad internal keyboard. I'm going to want to replace it. I need a little hardware help to do the work, I'm a software guy, not a hardware guy. I typically save a partition table, and then use partimage for backup, when backing up in this manor. I "think" I have enough space. Basically, I want to make sure software is saved so when it gets replaced, I lose nothing. Even the OS could possibly be replaced, but some of the files, CANNOT be replaced.
But partimage failed to work, probably because I see I'm using ext4, not ext3. This could be fixed, but for time, I just want to save it anyway. The OS for backup will be System Rescue CD running off of a ventoy USB stick. I typically use dd when partimage fails like that. I do a simple: Code:
dd if=<savedrive> of=<outputfile> But giving each command to the OS, to do the work, is tedious, and error prone. I CANNOT afford one error in this process. Can you help me write a script for this task? Then, I can include it with my standard scripts, in which case my process for backing up, would be: Code:
1. boot the disk I cannot afford to make mistakes, and need no sudo in the script, as a requirement, if sudo is needed, I will have to sudo it by the whole script. Code so far: Code:
#! /bin/bash |
Boot from some external device (dvd, usb) and backup the disk/partition without mounting it (or mounting it read/only mode).
Meta: maybe Programming forum is not optimal for this question. |
I wondered if it fits here or not. Gray area,i thought. As far as the backup, thats what im trying to do. Should i just copy the files? It wouldnt be as easy, but im wondering if efficiant.
|
Why are you using a tool that states on its homepage it is no longer developed, and trying to backup a filesystem that was never supported ???. Madness.
As suggested on that page use a supported tool - I like fsarchiver for this sort of thing. Seems you might need the some extra protection like the checksumming it offers. |
I'm using partimage because I always have, and the last I checked until now, there were no issues. If I can learn the new tool, I'd be happy to use it too, but I'm probably not going to right away convert every image. I am trying to backup a filesystem that had issues, because I didn't know it would. It's always worked for me, even windows, so I had no idea it would fail now.
Yes, extra protection would be great! I'll check into fsarchiver as I delete my files giving me trouble. |
I'll tell you how I would do this, although it's pretty different.
1) Use dd only to back up a very small portion of the drive near the start (basically only to back up the partition table and initial bootloader). 2) record the output of "fdisk -l" and "lsblk -f" just in case I need to recreate a partition's file system from scratch. Example output here: Code:
root@rapunzel:~# fdisk -l Example rsync: Code:
rsync -vaxAX --delete --progress /* /mnt/USBdrive/OSbackup/ In case I need to restore this, the steps are: 1) Use dd to restore the start of the drive. 2) Reformat the ext4 partition with GParted or something. Edit the UUID and Label if necessary. 3) Mount the ext4 partition and use rsync to copy the contents back. Example rsync: Code:
rsync -vaxAX --delete --progress /mnt/USBdrive/OSbackup/* /mnt/NewExt4Partition |
You can use gzip and split to divide the image in chunks (2G in this example) like:
Code:
dd if=/dev/sdx conv=sync,noerror bs=64K | gzip -c | split -a3 -b2G - /path/to/backup.img.gz Code:
cat /path/to/backup.img.gz* | gunzip -c | dd of=/dev/sdx |
I had a NAS corruption problem to deal with, before I had space to deal with this. I think part of my issue, is I don't have enough space, all on one drive. I need to be able to split some of this between drives. I will NOT neglect to study this last command, as I think that is what I was origionally looking for, if I could understand it. But now, I think, that just backing up my files, could be best, because of space issues, and really, my OS could be replaced, whereas the files mostly CANNOT. But backing them up to my NAS, or external drive, is good enough for me for now. I was just trying to do it the easiest way. Perhaps I will use ext3 if I ever rebuild it again.
Anyway, restarting my NAS, seems to have fixed my whole corruption problem, then I was able to delete the big files taking up space, in 2 seconds. And I didn't lose any other work now. Now I can try again to back up my files, now that I have space on the NAS. |
Hey, I've been where you are now, and my experience is - don't fear ext4. It will help more than it hurts, especially in eliminating those annoying bouts of long file system check on boot.
There are tools to do everything you need with ext4. |
All of that with the recommended programs and stuff, pretty much changed overnight as far as I could understand. That is why I had no idea that partimage is outdated now. It's by chance that I had ext4, and I thought that it would be supported. I heard now, it's the new "standard". I always when I knew, have been an ext* guy rather than reiserfs or anything like that. I have used reiserfs, but that was before I knew what my preferences were. Also, unless there's reasons to do so, on some server, I tend to stick to either of those two also, unless I'm on a server, or my distro recommends something else for some distro specific stuff.
I downloaded a new ISO, and will be migrating to the newer tool. But I'm glad I got the old version saved, as there's times it will be better going forward, for a transitional period. That's why my NAS is so important. I don't typically try to copy my whole NAS or anything for someone else, but I prefer programs which don't care if I distribute, and I then distribute "network" wide, which is the household, but so far, that's just me anyway. I don't always care if everything is 100% "free" by definition, at this point, just that it is a free as in beer, and allows that permission, so that I can keep a copy of the download, for reinstalling beyond where they support it. Less of that is now needed with Linux though. More pulling from the repository now. The overnight thing is how I can have no idea about that tech change, but it's a good thing, from my study. I've almost got the files on my NAS now, just one or so (folders) to go still. In the command above, is the final dash neccessary? Quote:
|
Once I know that command, when I can, it will be added to my command reference I'm creating. I'm doing what Distrotube says he does, going forward.
|
Have you read the man page for split? It is not an error. It isn't absolutely required but more of a convention for stdin.
Quote:
|
I read the man page, and missed that.
|
OK. I now understand the command given completely.
|
Just 4 hours, and all data will be copied off...
|
All times are GMT -5. The time now is 11:36 AM. |