Created
March 10, 2013 21:49
-
-
Save Chris2048/5130622 to your computer and use it in GitHub Desktop.
Great lost+found recovery script found at http://blog.windfluechter.net/content/blog/2011/03/30/1095-updated-automatically-restore-files-lostfound
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Usage: ./make-lsLR.sh | |
# | |
# Purpose: | |
# to make a file that is parseable for recovering | |
# a filled /lost+found directory by parsing | |
# filesize, md5sum, permisions and path+filename | |
# | |
# Author: Ingo Juergensman - http://blog.windfluechter.net | |
# License: GPL v2, see http://gnu.org for details. | |
# | |
# first: get all directories | |
# fail silently when a Xen Kernel is loaded | |
if [ `uname -r | grep xen-686` ]; then | |
exit 0 | |
fi | |
# check whether a full backup is running on this host or not | |
check_full=`su - backuppc -c "/usr/share/backuppc/bin/BackupPC_serverMesg status jobs muaddib" | grep '"type" => "full"'` | |
while [ -n "$check_full" ]; do | |
check_full=`su - backuppc -c "/usr/share/backuppc/bin/BackupPC_serverMesg status jobs muaddib" | grep '"type" => "full"'` | |
# echo "Fullbackup running" | |
sleep 300 | |
done | |
nice -20 find / -path /sys -prune -o \ | |
-path /proc -prune -o \ | |
-path /var/lib/backuppc -prune -o \ | |
-path /var/spool/squid -prune -o \ | |
-path /media -prune -o \ | |
-path /mnt -prune -o \ | |
\( -name .AppleDouble -o -name .AppleDB -o -name .AppleDesktop \) -prune -o \ | |
-type d -printf "%U:%G %#m " -print > /root/ls-md5sum-dirs.txt.new | |
# next: get all relevant information | |
nice -20 find / -path /sys -prune -o \ | |
-path /proc -prune -o \ | |
-path /var/lib/backuppc -prune -o \ | |
-path /var/spool/squid -prune -o \ | |
-path /media -prune -o \ | |
-path /mnt -prune -o \ | |
\( -name .AppleDouble -o -name .AppleDB -o -name .AppleDesktop \) -prune -o \ | |
-type f -printf "%s %U:%G %#m " \ | |
-exec nice -15 md5sum {} \; | tr -s " " > /root/ls-md5sum-files.txt.new | |
# keep a backup file | |
if [ -e /root/ls-md5sum-dirs.txt ]; then | |
#echo "mv dirs.1" | |
mv /root/ls-md5sum-dirs.txt /root/ls-md5sum-dirs.txt.1 | |
if [ -e /root/ls-md5sum-dirs.txt.1.gz ]; then | |
#echo "rm dirs" | |
rm /root/ls-md5sum-dirs.txt.1.gz | |
fi | |
gzip -9 /root/ls-md5sum-dirs.txt.1 | |
fi | |
if [ -e /root/ls-md5sum-files.txt ]; then | |
#echo "mv files.1" | |
mv /root/ls-md5sum-files.txt /root/ls-md5sum-files.txt.1 | |
if [ -e /root/ls-md5sum-files.txt.1.gz ]; then | |
#echo "rm files" | |
rm /root/ls-md5sum-files.txt.1.gz | |
fi | |
gzip -9 /root/ls-md5sum-files.txt.1 | |
fi | |
mv /root/ls-md5sum-dirs.txt.new /root/ls-md5sum-dirs.txt | |
mv /root/ls-md5sum-files.txt.new /root/ls-md5sum-files.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment