37
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 ...
answered Jun 8 '15 at 1:00
Gilles 'SO- stop being evil'
668k162162 gold badges13941394 silver badges18951895 bronze badges
15
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 ...
answered Aug 17 '14 at 0:36
Gilles 'SO- stop being evil'
668k162162 gold badges13941394 silver badges18951895 bronze badges
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
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 ...
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
...
answered Aug 13 '19 at 15:16
Stephen Kitt
280k3434 gold badges686686 silver badges770770 bronze badges
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
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
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-...
answered Aug 18 '14 at 0:55
Gilles 'SO- stop being evil'
668k162162 gold badges13941394 silver badges18951895 bronze badges
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
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
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 ...
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 ...
4
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 ...
4
e2image can be used to create an image of an ext4 file system, while only copying sectors which are in use:
e2image -ra /dev/sda1 /path/to/file.img
file.img will be created as a sparse file, so it will only occupy the space which is really used in the file system, even though its apparent size will reflect the capacity of the file system.
You can also use ...
answered Sep 12 '19 at 14:06
Stephen Kitt
280k3434 gold badges686686 silver badges770770 bronze badges
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.
answered Oct 30 '12 at 21:20
Stéphane Chazelas
404k7171 gold badges795795 silver badges12071207 bronze badges
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
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
Short answer: yes this works fine.
Longer answer: I used dd to restore the data as above, and it was successful. However, the Mac wouldn't load the OS upon power-on. Picking the HDD from the startup device menu allowed it to boot fine and all of the data was there. I loaded the Mac into recovery mode and ran first aid on the disk, and after doing this it ...
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 ...
2
You can SSH to your server, CAT your file into a pipe to GUNZIP after what you can pipe the uncompressed output to DD, which will then write the file to the disk of your choice.
ssh user@host cat /path/to/image.img.gz | gunzip | sudo dd of=/dev/sdX
You can also improve on this by using PIGZ (Parallel Gzip) instead of GUNZIP to decompress your file. This is ...
2
Fortunately I still had a copy of the corrupted filesystem, so I had some idea of what should go in /var/cache for my system.
cd /var/cache
sudo mkdir apache2 apt ddclient debconf dictionaries-common fontconfig ldconfig man modsecurity
sudo chmod a=,u=rwx ldconfig
sudo chmod g=rsx man
sudo chown man man
sudo chown www-data modsecurity
sudo mkdir apache2/...
Only top voted, non community-wiki answers of a minimum length are eligible
Related Tags
restore × 140backup × 71
linux × 21
debian × 13
dd × 12
ubuntu × 10
partition × 10
rsync × 9
filesystems × 8
lvm × 7
snapshot × 6
dump × 6
windows × 5
freebsd × 5
tar × 5
btrfs × 5
duplicity × 5
permissions × 4
linux-mint × 4
data-recovery × 4
mv × 4
cloning × 4
centos × 3
rhel × 3
git × 3