ddrescue

I have written about ddrescue in an article before, but just mentioned it without explaining how to use it.

As I had to use it again this weekend, here is how things go:

Install ports

1. Go to:https://www.macports.org/install.php and download your ports version of choice.
2. reboot
3. sudo port -v selfupdate

Install ddrescue

sudo port install ddrescue

This can even go without xcode:

Warning: xcodebuild exists but failed to execute
Warning: Xcode does not appear to be installed; most ports will likely fail to build.

Test installation:

ddrescue --help
GNU ddrescue - Data recovery tool.
Copies data from one file or block device to another,
trying to rescue the good parts first in case of read errors.

Usage: ddrescue [options] infile outfile [mapfile]

Always use a mapfile unless you know you won't need it. Without a
mapfile, ddrescue can't resume a rescue, only reinitiate it.
NOTE: In versions of ddrescue prior to 1.20 the mapfile was called
'logfile'. The format is the same; only the name has changed.

If you reboot, check the device names before restarting ddrescue.
Do not use options '-F' or '-G' without reading the manual first.

Options:
  -h, --help                     display this help and exit
  -V, --version                  output version information and exit
  -a, --min-read-rate=    minimum read rate of good areas in bytes/s
  -A, --try-again                mark non-trimmed, non-scraped as non-tried
  -b, --sector-size=      sector size of input device [default 512]
  -B, --binary-prefixes          show binary multipliers in numbers [SI]
  -c, --cluster-size=   sectors to copy at a time [128]
  -C, --complete-only            do not read new data beyond mapfile limits
  -d, --idirect                  use direct disc access for input file
  -D, --odirect                  use direct disc access for output file
  -e, --max-errors=[+]        maximum number of [new] error areas allowed
  -E, --max-error-rate=   maximum allowed rate of read errors per second
  -f, --force                    overwrite output device or partition
  -F, --fill-mode=        fill blocks of given types with data (?*/-+l)
  -G, --generate-mode            generate approximate mapfile from partial copy
  -H, --test-mode=         set map of good/bad blocks from given mapfile
  -i, --input-position=   starting position of domain in input file [0]
  -I, --verify-input-size        verify input file size with size in mapfile
  -J, --verify-on-error          reread latest good sector after every error
  -K, --skip-size=[,]  initial size to skip on read error [64 KiB]
  -L, --loose-domain             accept an incomplete domain mapfile
  -m, --domain-mapfile=    restrict domain to finished blocks in file
  -M, --retrim                   mark all failed blocks as non-trimmed
  -n, --no-scrape                skip the scraping phase
  -N, --no-trim                  skip the trimming phase
  -o, --output-position=  starting position in output file [ipos]
  -O, --reopen-on-error          reopen input file after every read error
  -p, --preallocate              preallocate space on disc for output file
  -P, --data-preview[=]   show some lines of the latest data read [3]
  -q, --quiet                    suppress all messages
  -r, --retry-passes=         exit after  retry passes (-1=infinity) [0]
  -R, --reverse                  reverse the direction of all passes
  -s, --size=             maximum size of input data to be copied
  -S, --sparse                   use sparse writes for output file
  -t, --truncate                 truncate output file to zero size
  -T, --timeout=       maximum time since last successful read
  -u, --unidirectional           run all passes in the same direction
  -v, --verbose                  be verbose (a 2nd -v gives more)
  -w, --ignore-write-errors      make fill mode ignore write errors
  -x, --extend-outfile=   extend outfile size to be at least this long
  -X, --exit-on-error            exit after the first read error
  -y, --synchronous              use synchronous writes for output file
  -1, --log-rates=         log rates and error sizes in file
  -2, --log-reads=         log all read operations in file
      --ask                      ask for confirmation before starting the copy
      --cpass=[,]          select what copying pass(es) to run
      --max-read-rate=    maximum read rate in bytes/s
      --pause=         time to wait between passes [0]
Numbers may be in decimal, hexadecimal or octal, and may be followed by a
multiplier: s = sectors, k = 1000, Ki = 1024, M = 10^6, Mi = 2^20, etc...
Time intervals have the format 1[.5][smhd] or 1/2[smhd].

Exit status: 0 for a normal exit, 1 for environmental problems (file
not found, invalid flags, I/O errors, etc), 2 to indicate a corrupt or
invalid input file, 3 for an internal consistency error (eg, bug) which
caused ddrescue to panic.

Report bugs to bug-ddrescue@gnu.org
Ddrescue home page: http://www.gnu.org/software/ddrescue/ddrescue.html
General help using GNU software: http://www.gnu.org/gethelp

Find the right disk

diskutil list

Start ddrescue

sudo ddrescue -v /dev/disk3s2 /Volumes/backup/failing_drive_backup.dmg failing_drive_backup.log
GNU ddrescue 1.20
About to copy an unknown number of Bytes from /dev/disk3s2 to /Volumes/backup/failing_drive_backup.dmg.
    Starting positions: infile = 0 B,  outfile = 0 B
    Copy block size: 128 sectors       Initial skip size: 128 sectors
Sector size: 512 Bytes

Press Ctrl-C to interrupt
rescued:     7621 MB,   errsize:         0 B,    current rate:  10878 kB/s
   ipos:     7621 MB,    errors:         0,      average rate:  10484 kB/s
   opos:     7621 MB,  run time:      12m 7s,  remaining time:         n/a
time since last successful read:          0s

Faster

Found an good recommendation from Christian Schwang:

– instead of /dev/disk{x} you may use /dev/rdisk{x} – This will give a massive performance boost (in my testing transfer rate went from 30 MB to 130 MB). For detailed reason you may want to look at: http://lists.apple.com/archives/filesystem-dev/2012/Feb/msg00015.html

Result with the same drive as above:

sudo ddrescue -v /dev/rdisk3s2 /Volumes/backup/failing_drive_backup2.dmg failing_drive_backup2.log
Password:
GNU ddrescue 1.20
About to copy an unknown number of Bytes from /dev/rdisk3s2 to /Volumes/backup/failing_drive_backup2.dmg.
    Starting positions: infile = 0 B,  outfile = 0 B
    Copy block size: 128 sectors       Initial skip size: 128 sectors
Sector size: 512 Bytes

Press Ctrl-C to interrupt
rescued:     5215 MB,   errsize:         0 B,    current rate:  34209 kB/s
   ipos:     5215 MB,    errors:         0,      average rate:  33649 kB/s
   opos:     5215 MB,  run time:      2m 35s,  remaining time:         n/a
time since last successful read:          0s

Known issues

drescue: Can't open input file: Resource busy

Solution: Open the DiskUtility.app, and on your to-be-recued-drive, unmount any of it’s partitions.
Warning: Do not eject the USB hard drive.

more infos

https://derflounder.wordpress.com/2012/01/31/using-ddrescue-on-a-failing-hard-drive/

OpenOffice problem window restore

If your OpenOffice crashed running Apple OSX, you might run into a problem where a dialog is asking you wether you would like to restore your old windows / documents.

When you click one of the two options, nothing happens.

You can solve the problem (make a backup of the folder before deleting it):

THIS IS ON YOUR OWN RISK!

Quit open office (using task manager or alt+cmd+esc)
Open Terminal
cd  ~/Library/Saved Application State/org.openoffice.script.savedState
rm -rf *

That will delete all content of that folder.

Recovering Photos From Bad Storage Cards (with ddrescue)

Today, Jonathan Zdziarski wrote a Blog post about recovery of Photos on a corrupt SD card. In total, the article is very good, but I would prefer to use ddrescue instead of dd only.

Had good expieriences with ddrescue in the past while recover data from SD cards and HDDs as well.

Hope this helps

Raspberry Pi Backup script

Hier mal ein Tipp zum Wochenende zu einem Raspberry Pi Backup script welches ganz modular angesteuert werden kann.

Zur Auswahl stehen dd, tar, rsync und xbmc.
Es kann auch ausgewählt werden, welche Anzahl an Backups vorgehalten werden soll.

Die Backups können dabei auf z.B. ein Qnap NAS, oder eine externe Festplatte gespeichert werden.

Das Backup script ist hier erhältlich.

TimeMachine Backup per AFP mounten und reparieren

Um ein TimeMachine Backup zu reparieren, welches z.B. auf einem NAS liegt, kann man folgende Herangehensweise versuchen:

0. Sichern des Images

Bevor man irgenwelche Schritte durchführt, sollte man das Image sichern

„cp /share/TMBackup/Name.sparebundle /home/user/foo“

1. Mounten des Images auf dem Mac

sudo mkdir /Volumes/temp

sudo mount -t afp afp://user:pass@192.168.x.x/home/user/foo /Volumes/temp

oder alternativ über den Finder.

Über den Befehl findet man heraus ob es eingebunden wurde

mount

2. Image mit hdiutils bearbeiten

hdiutil attach -nomount -readwrite Name.sparsebundle

 

Ergebnis:

/dev/disk3              Apple_partition_scheme
/dev/disk3s1            Apple_partition_map
/dev/disk3s2            Apple_HFSX

wobei disk3 durchaus variieren kann

3. Fsck durchführen

fsck_hfs -rf /dev/disk3s2

 

4. warten

** /dev/rdisk3s2    Using cacheBlockSize=32K cacheTotalBlock=16384 cacheSize=524288K.   Executing fsck_hfs (version diskdev_cmds-557.3~1).** Checking Journaled HFS Plus volume.** Detected a case-sensitive volume.   The volume name is Time Machine-Backups** Checking extents overflow file.** Checking catalog file.** Rebuilding catalog B-tree.

 

Achtung: Das Image muss mit Schreibrechten gemounted werden, sonst kann nichts repariert werden.

Bei dem Fehler:

** /dev/rdisk3s2 (NO WRITE)
Can’t open /dev/rdisk3s2: Permission denied

Ggf. versuchen den Befehl per sudo auszuführen.

See:

http://tonylawrence.com/blog/2012/08/11/fixing-corrupted-time-machine-backups/

http://blog.jthon.com/?p=31

Wer sich fragt was TimeMachine ist – TimeMachine ist die Backup Technik, vorgestellt am 26. Oktober 2007 mit der OSX Version 10.5 Leopard eingeführt wurde. Die Speicherung erfolgt auf HFS formatierte Festplatten / Netzlaufwerke. Apple vertreibt auch einige Hardware mit TimeMachine unterstützung die als Speichermedium dienen. Einige NAS Hersteller haben mittlerweile auch TimeMachine Server Funktionalität eingebaut.

Getdropbox – manage files from everywhere

Im neuen Jahr der erste Beitrag über eine Dienstleistung / Applikation die mir die letzten Monate die tägliche Arbeit erheblich erleichtert hat: getdropbox.com

Angeboten wird dort nach Anmeldung eine Online-Verwaltng für die eigenen Dateien. Das Besondere ist die Flexibilität und Einfachheit, so können die Dateien von überall per Web Interface verändert, gelöscht, verschoben oder auf den zugreifenden Rechner heruntergeladen werden. Neben dem Browserzugriff sind Applikationen für Windows, Apple Mac OS und Linux verfügbar. So kann auf jedem eigenen Rechner das Programm installiert werden und nach Eingabe der Accountdaten hällt die Software die Dateien automatisch auf dem aktuellsten Stand. So wird nach getaner Schreibarbeit am Notebook während einer Zugfahrt beim nächsten Internetzugriff automatisch die neuesten Versionen hochgeladen und sind dann am heimischen PC verfügbar und können verfeinert werden.

Neben der reinen Synchronisation der Dateien wird im Hintergrund auch eine Versionierung der Dateien vorgenommen, ein Rückspung zu einer alten Version ist somit kein Problem, selbst ein versehentliches Löschen einer Datei / eines Ordners stellt kein Problem dar, gelöschte Inhalte können wiederhergestellt werden.

Die Software verhällt sich auf dem lokalen Rechner sehr zurückhaltend und wird nur in Form eines Ordners genutzt, der sich in die Dokumente respektive Eigenen Dateien eingliedert.

Um das Angebot rund zu machen, hat man über die Web Schnittstelle die Möglichkeit, Dateien mit anderen gemeinsam zu bearbeiten via Share, oder aus einer Sammlung von Bilddateien ohne weitere Eingriffe ein simplex attraktives Webalbum der Bilder zu generieren.

Zusamenfassend liefert die Software: Synchronisation, Versionierung, Plattformunabhängigkeit, Rechnerunabhängigkeit, Datensicherung und Publizierung von Bildern

Bei der kostenlosen Mitgliedschaft sind 2.0 GB Speicherplatz verfügbar, 50 GB erhällt man für 9,99 $ / Monat bzw. 99 $ / Jahr. Zum Austausch der eigenen Dateien, Arbeitsdokumente und einigen Bildern sollten 2 GB aber ausreichend sein.

Weitere Artikel:

Artikel auf Apfelquak

freewareosx

Artikel über drop.io auf BasicThinking

Backup einer MYSQL Datenbank in Shellscript

Um eine Datenbank über ein Shellscript zu sichern bietet sich mysqldump an.

Wenn man dabei einen Server hat, der nicht gleich dem Datenbankserver ist, muss die Datenbank remote gesichert werden, mysqldump bietet dabei an, per Option einen Host anzugeben. Daraus wird dann der folgende Befehlt, der in einem Backup Script verwendet werden kann:

mysqldump -u USER -pPASSWORT -h HOST DATENBANKNAME > backup.sql

Kein aktivierbares Dateisystem Fehler 254

Wer versucht, bei Apples Betriebssystem OSX von einem .dmg Image wiederherzustellen kann auf folgende Fehler stoßen:

Kein aktivierbares Dateisystem

bzw.

Fehler 254

Der eine Fehler tritt auf, wenn man das .dmg Image öffenen will, obwohl es auf einer USB Platte liegt, der andere Fehler kommt beim Versuch, das Image auf eine Partition zu mounten.

Eine Internetrecherche bringt hierzu keinerlei hilfreicher Ergebnisse. Eine mögliche Ursache dürfte wohl eine Beschädigung des Images sein, eine Reparatur ist sehr aufwendig.

Sinnvoll ist es aber allemal, sich ein Image der Installations DVD zu erstellen, da die Geschwindigkeit der Installation dadurch deutlich erhöht wird.

Backup mit wget

Um das Backup einer Webseite per FTP zu holen, bietet sich das Tool wget an. Dieses steht unter der GNU Lizenz. Wget bietet viele Optionen, wie z.B. das Fortsetzen von abgebrochenen Downloads.

Um ein komplettes FTP Dir zu sichern bietet sich folgendes Script an:

SELECT=`date ‚+%w’`
WEEK=`date ‚+%W’`

mkdir /backup/${WEEK}_Backup-${SELECT}
wget -x -r –cache=off -N ftp://USERNAME:PASSWORT@HOST -P /backup/${WEEK}_Backup-${SELECT} -o /backup/logdatei.log

Die einzelnen Parameter kann man mittels man wget nachschlagen.