Hot answers tagged

34

Package management is one of the main differentiators between distributions. Between unrelated distributions, you won't be able to do anything automatic. Different distributions break down software into different sets of packages and use different names. Between machines running the same version of the same distribution, you can achieve a similar ...


14

# take a read-only snapshot: btrfs sub snap -r fs snapshot ... do things on fs # rolling back: btrfs sub del fs # at which point you'll lose those things you've done # if you want to preserve them, just rename fs instead btrfs sub snap snapshot fs # reinstate snapshot as a read+write fs btrfs sub del snapshot # delete the non-longer ...


13

It's really easy - use the --force flag. duplicity --force file:///home/user/Backup / This will probably not only restore missing files to the directories you've backed up, but also replace newer versions of backed up files if they exist, but it's better than nothing.


10

If you're staying within the Debian family, yes, you can transfer them very easily. Just list the currently installed packages, save them to a file and then read that file to reinstall them: Save the installed packages in the file installed: dpkg -l | grep ^ii | awk '{print $2}' > installed In your newly installed Debian-based distro, install the saved ...


9

Restore You can restore the image back to your replacement HDD with something along the lines of: # dd if=backup.img of=/dev/sd? You will end up with a clone of your original disk including all partitions and data. The downside to this is that the partitions won't be resized by dd so your replacement disk must be identical to or larger in capacity than ...


8

Assume that you have # at beginning of comment lines, so you can do: yum -y install $(awk '!/^#/' list) !/^#/ cause awk to ignore any lines that start with #, print the rest.


7

/var/cache is not a free-for-all like /var/tmp. Each service that requires it has a subdirectory in /var/cache with appropriate permissions for it to store files. On Debian and derived distributions, you can run dpkg -S /var/cache to find what packages have set up directories under /var/cache, and apt-get --reinstall install PACKAGE_NAME … to reinstall ...


6

To get true atomicity, you would need to use filesystem-level features like btrfs snapshots.


6

You can restore your home directory, or all home directories (i.e. all of /home), /usr/local, and /root wholesale and indiscriminately. For the rest: /usr: don't restore this at all (except for /usr/local). The contents are all managed by the Debian package manager. Just get the files back by reinstalling the same packages you had before. In fact, unless ...


5

GNU chmod can take a reference file: --reference=RFILE use RFILE's mode instead of MODE values If the folder structure of your back remains the same, you could do something like: cd /path/to/backup find . -exec chmod --reference={} --changes /source/of/{} \; /source/of is the path from which the backup was done. Now you can use find's tests to only ...


5

On Linux at least, you can access all files which a process still has open, in /proc/${pid}/fd: $ echo Test > removeme $ sleep 1200 < removeme & [1] 21954 $ rm removeme $ ls -l /proc/21954/fd total 0 lr-x------. 1 skitt skitt 64 Aug 13 17:14 0 -> '/home/skitt/tmp/removeme (deleted)' lrwx------. 1 skitt skitt 64 Aug 13 17:14 1 -> /dev/pts/7 ...


5

It's possible for dd conv=sync,noerror (or dd conv=noerror,sync) to corrupt data in some cases. However in your case it's probably simply surplus zeroes at the end of file. If your device is not exact multiple of 64K, your dd command would have filled the last 64K block with zeroes in the image file. And those additional zeroes can't be restored. Which ...


4

Try from the other side: create R/W snapshot, use it as new main one, do "some experiments" on old one, then just drop contents of old. Article "BTRFS Fun" can be helpful.


4

I suggest you to use rsync instead of backuping your files manually. With this tool, you can do exactly what you're doing with some extra features. For example, you can pass the --progress argument to know the last file copied. Another feature is that you can copy only the new files or the modified ones, which will reduce the amount of data transmitted ...


4

You can use some marker file, when the restore is complete. When the restore is incomplete and the marker file is missing, you know you must remove the incomplete restore.


4

Yes, just use for restore image from Clonezilla: cat sda5.ext3-ptcl-img.gz.a* | gunzip -c | partclone.restore -d -s - -o /dev/sda5


4

There are very few files that absolutely must be different between two machines, and need to be regenerated when cloning: The host name /etc/hostname. The SSH host keys: /etc/ssh_host_*_key* or /etc/ssh/ssh_host_*_key* or similar location. The random seed: /var/lib/urandom/random-seed or /var/lib/random-seed or similar location. (/var/lib/systemd/random-...


4

First of all you should be aware of slapcat's limitations: For some backend types, your slapd(8) should not be running (at least, not in read-write mode) when you do this to ensure consistency of the database. It is always safe to run slapcat with the slapd-bdb(5), slapd-hdb(5), and slapd-null(5) backends. So you better pack that backup in /etc/init.d/...


4

Solved it with help of the accepted answer here: Can overwritten files be recovered? For larger files that may be in multiple non-contiguous blocks, I do this: grep -a -b "text in the deleted file" /dev/sda1 13813610612:this is some text in the deleted file which will give you the offset in bytes of the matching line. Follow this with a series of ...


4

If the disks are recognized from your OS the command: zpool import should be enough to get the pool imported and visible in your current OS. You can check the status with command zpool status You can try to import it explicitly by name zpool import ZStore P.S. Do not forget to set the pool online: zpool online You can check zpool-features features ...


3

I just had to restore a partition from one of my image backups. Steps: As my backup was to an external nfs drive, I booted of the clonezilla cd, start clonezilla select device image select nfs-server, static I configured my nfs drive to use clonezilla defaults, so I just hit enter several times, you may have to enter ip's, masks, shares, etc. ...


3

Not directly, no. The best you can do is restore and verify to a temporary directory, then rename. The rename will move the files to their proper position atomically.


3

Well, given that FreeBSD is opensource, you could simply port FreeBSD's restore to your operating system. Cygwin might help you there as it emulates some of the Unix API so there would be fewer things you need to adapt to make it work.


3

Adding to Orion's answer, I would also throw Clonezilla in to the mix. A FOSS alternative to Ghost and Acronis.


3

Some useful notes to help you achieve your goal: You can get a list of installed packages and their versions by running: dpkg-query -W You can create an archive of .deb packages of all currently installed packages by installing dpkg-repack and running something like this: dpkg-query -W | awk '{print $1}' | xargs dpkg-repack This will dpkg-repack all ...


3

cat archive.*tar |tar xvf - -g /dev/null --ignore-zeros -C destination At the end of tar files, is the 'end-of-archive' marker (2x 512 blocks of zero bytes. Tar will continue to read past the marker in some cases, but will not take any data. --ignore-zeroes will tell it to keep reading regardless. Related: Tar supports appending to archives; it does this ...


3

We can get the list of files with the changed permissions by rsync -ani rsync -ani newFile new/ | awk {'print $2'} then we can pass the output to chmod and use the output for reference file from backup to original file where the permissions have been changed: rsync -ani newFile new/ | awk {'print $2'} | xargs -I@ chmod --reference=new/@ @ I tried to ...


3

The command you need is: apt-get install --reinstall tzdata Background To know which package contains the file you damaged, you could do a dlocate -S /usr/share/zoneinfo/America/Puerto_Rico or dpkg-query -S /usr/share/zoneinfo/America/Puerto_Rico which will tell you that the file is in the package tzdata. Once you know that, it's just a matter of ...


3

As root, just cat the partition to another partition: cat /dev/sdXn > /dev/sdYi or to a file: cat /dev/sdXn > backup.img Or to a file or partition on another machine: cat /dev/sdXn | ssh user@host 'cat > backup.img' You could use dd instead of cat, but there's no good reason to do so: dd if=/dev/sdXn of=backup.img Or if you want a progress bar ...


2

I think what you're looking for is 3rd party image backup and restoration software, like Acronis TrueImage or Norton Ghost. Both can take both partition and whole image backups, which I think is what you're looking for.


Only top voted, non community-wiki answers of a minimum length are eligible