Showing posts with label backup. Show all posts
Showing posts with label backup. Show all posts

Monday, February 18, 2019

how to restore files from backup with duplicity

duplicity restore --no-encryption --file-to-restore "some/directory with space in its name" --time "2019-02-17T18:00:05+07:00" file:///data/my-important-backup-dir

Wednesday, December 19, 2012

harddisk ของ Western Digital มีปัญหากับ RAID-1

หากท่านนำ harddisk ของ Western Digital มาใส่เป็น member ของ RAID-1 ท่านจะพบปัญหาการ rebuild ไม่จบ โดย status ของ raid เมื่อดูด้วย mdadm จะเป็น clean, degraded และ spare rebuilding

สาเหตุเกิดจาก module NCQ ใน harddisk ท่านต้อง disable ที่ sysctl.conf เพิ่มบรรทัด (สมมติ harddisk ลูกนั้นคือ /dev/sdb):

block/sdb/device/queue_depth=1


References

Saturday, April 30, 2011

backup ntfs partition ผ่าน network

เมื่อไม่กี่วันมานี้เพื่อนร่วมโลกท่านหนึ่งที่ผมได้เคยให้ยืม computer laptop ของ vaio ไป ได้นำมันกลับมาคืนให้กับผมเนื่องจากมันไม่มีประโยชน์อันใดกับเขาอีกแล้ว อีกทั้งเขายังมีคอมพิวเตอร์เครื่องใหม่ไปแล้วด้วย ก็นับว่าเป็นเรื่องที่น่ายินดีต่อทุกฝ่าย

คอมพิวเตอร์เครื่องนี้มี Windows XP Pro ติดตั้งไว้อยู่ โดยแบ่ง partition ไว้สองอันได้แก่ C: partition และ D: partition ซึ่งโดยส่วนตัวแล้วผมนิยมให้ Windows ที่ผมใช้มีเพียง partition เดียวเท่านั้นคือ C: (สามารถดู blog ที่เกี่ยวเนื่องได้ ที่นี่ {หากลิงก์ไม่เวิร์กแสดงว่าผมยังไม่ได้เขียน})

ด้วยเหตุนี้ผมจึงทำการติดตั้งโปรแกรมตัวหนึ่งซึ่งค้นเจอจาก google ชื่อ EASEUS Partition Master Home Edition:


http://www.easeus.com/download.htm

ลงไปใน Windows XP ตัวนี้ จากนั้นก็ทำการ ลบ D: partition ให้เรียบร้อยซึ่งมันจะถูกเปลี่ยนไปเป็น free space แล้วเราจึงสามารถขยาย C: partition ให้เต็ม ทั้ง harddisk ได้โดยง่าย (อย่าลืม backup ข้อมูลที่อยู่ใน D: partition ก่อนนะครับ)

ทีนี้ผมเพิ่งสังเกตเห็นว่าเจ้าเครื่องอ่านแผ่น cd/dvd ของคอมเครื่องนี้มันอ่านแผ่นไม่ได้ซะแล้ว เหอ เหอ ประกันก็หมด นี่หมายความว่าหากผมต้องทำการติดตั้งวินโดวส์ใหม่นี่คงต้องไปหาซื้อ external cdrom ไรงี้มาแหงเลย

แอะ แต่ช้าก่อน ไอ่ vaio เครื่องนี้นี่จำได้ว่ามัน boot จาก usb ได้นี่นา วะ ฮะ ฮะ แบบนี้ต้องใช้ประโยชน์จาก grml สักหน่อยแล้ว

เมื่อปลายปีที่แล้วผมได้ทำการติดตั้ง grml ลงไปใน usb handy drive ขนาด 8GB ของผมโดยการบู้ท grml ขึ้นมาจาก live cd, เสียบ usb handy drive เข้าไป จากนั้นก็เพียงใช้คำสั่ง:

# grml2hd /dev/sda1

grml ก็จะถูกติดตั้งลงไปยัง handy drive เป็นอันเรียบร้อย ในที่นี้ผมได้แบ่ง partition ไว้หนึ่งอันคือ /dev/sda1 สำหรับเนื้อที่ก็ทั้งหมดที่มือก็ประมาณ 8GB นั่นแล

ทีนี้ก็นำไอ่ grml usb อันนี้มาเสียบกับเจ้า vaio น้อย เปิดเครื่อง ขึ้นมา กด f2 หากต้องการเข้า bios เพื่อเข้าไปตั้งค่าให้ boot จาก usb ได้

เมื่อ boot ขึ้นมาแล้วผมก็ใช้ fdisk -l ก็พบว่า windows xp นั้นถูก install อยู่ใน /dev/sda1 โดย ใช้ file system format เป็น ntfs ตามคาด ทีนี้ก็ backup มันทั้ง parition ซะเลยเวลามีปัญหาจะได้ลงใหม่ง่ายๆ ก็เปิดเครื่อง unix อีกเครื่องใน LAN เดียวกันเอาไว้ ที่มี sshd รันอยู่นะครับ ในกรณีผมก็เป็น macosx สมมติว่า ชื่อเครื่อง mymacosx ละกันนะครับ ที่ grml usb บน vaio เราก็พิมว่า:

# mkdir macosx
# sshfs unsigned_nerd@mymacosx:backup macosx
# ntfsclone --save-image --output macosx/anyname.img /dev/sda1

ถ้าใช้ sshfs ไม่เป็น comment มาถามกันได้นะครับ

ก็ถือเป็นโชคดีของเราหละนะครับที่มีคำสั่งเฉพาะสำหรับการสร้าง disk image ของ partition ที่เป็น ntfs ไม่งั้นเนี่ยถ้าต้องใช้ dd มาทำแล้วมันจะช้ากว่า ยากกว่า ต้องมานั่งคิดว่าจะใส่ option ต่างๆ แบบไหนถึงจะเหมาะสม ใส่ผิดเดี๋ยวยุ่งอีก

อันที่จริงอีกโปรแกรมที่ดีก็คือ partimage แต่ว่าจาก man page (ของ grml 2009.10 Hello-Wein) พบว่า partimage ยังไม่รองรับ ntfs file format อย่างสมบูรน์ (experimental only) ผมก็เลยคิดว่าเราใช้ ntfsclone ไปก่อนดีกว่า เพื่อความปลอดภัย

Friday, August 13, 2010

how to sync ftp directory with a local directory in linux [part 2]

I did some more research and found out that lftp can accomplish my requirement!

All you have to do is to pass the following options to lftp : "-c -e"

Here is an example.  I have a file ~/main.conf:

open ftp.somehost.com
user someuser@somehost.com somepassword
set ftp:ssl-allow no
mirror -c -e
exit

I also have another shell script to call lftp with proper configuration, lftp-mirror.sh:

#!/bin/zsh

cd ~/projects/somehost-ftpdir
lftp -f ~/main.conf

I then call lftp-mirror.sh everytime I want to sync my local directory with the ftp server.

Please see previous blog post:

how to sync ftp directory with a local directory in linux [part 1]


Monday, July 26, 2010

external harddisk access error in macosx

I have a 1TB external harddisk connected to my MacMini via USB port.  I used it for:
  • Back up with Apple's TimeMachine
  • Back up other data
  • Store movies and softwares
Just today when I turned my machine on there was no disk icon shown in either Finder or Desktop.  I went to Disk Utility (a gui disk management for MacOSX) where I could still see my external harddisk listed.  I was so sure something really went wrong.

In Disk Utility, I tried clicking both Verify Disk button and Repair Disk button.  None of them worked as you can see from the screenshot:


This is frightening.  I then went to shell in Terminal and tried fsck like this:

$ fsck_hfs  /dev/disk1s2

And here is what I got:

** /dev/rdisk1s2 
** Checking Journaled HFS Plus volume.
** Detected a case-sensitive catalog.
   Invalid node structure
(4, 0)
   Invalid B-tree node size
(4, 0)
   Invalid node structure
(4, 0)
   Invalid B-tree node size
(4, 0)
** Volume check failed.

(Note that I knew it was /dev/disk1s2 from the command "diskutil list".)

The error message looks the same as what I got from Disk Utility.  I found later that Disk Utility's Repair Disk button made use of fsck which is why it yielded the same result.

I also tried attaching the harddisk with my Grml Linux laptop and mounted it as hfsplus.  I could see all the files there (and of course, I can access all files and even copy them to anywhere else so my ass is still safe).  Though, fsck.hfsplus in Linux did not work either.

After spending time researching about this issue, I can conclude that:
  • This is a rare case (assuming my harddisk is still in a good condition as I just recently bought it).
  • fsck is not the right tool to fix this special case.
  • All lead me to use Disk Warrior to fix the problem in my harddisk.  People claim it knows hfsplus file system more than fsck_hfs.
And it just worked!  Here are the steps it took:
  1. Open Disk Warrior
  2. Under Directory tab, choose your external harddisk device in a drop down list
  3. Click Rebuild and wait for a long while depends on how much damage and how large your harddisk is
  4. Once it's done, it will popup a report telling us what kinds of damages it detects and etc.  All we have to do is to click Replace button and wait for another while
  5. And that's it!
Good luck, everyone : )

Sunday, July 25, 2010

how to sync ftp directory with a local directory in linux [part 1]

Surprisingly, I could not find a (free and opensource) tool in Linux that states precisely in their manuals that they support syncing directory in ftp with a local directory in my computer.

That I said "syncing" I mean it will only fetch the changes from the last sync into my local directory only instead of re-downloading the whole thing again which can be cumbersome.

That I said "ftp", yes, I really mean the retarded ftp which I am always against it.  If I could, I would never use ftp.  As you may already guess, I have to use it as I have no choice.  The company I work with subscribe to several shared web hostings which usually come with retarded ftp server as the only mean to transfer files between our local computer and the servers which just totally SUCKS.

The first thing came up to my mind was,  of course, rsync - but the problem is that it does not support ftp.

The second thought was to use "mirror" command of lftp.  However, the manual page does not say exactly whether or not it does "sync".  I have a hunch that it can only downloads new files but can't keep the local directory in sync with what are on the ftp server.  So this does not work either.

The third idea is what I chose.  Though, later I found that there were problems due to low quality of local ADSL Internet connection and etc which made it difficult to download directory that had many subdirectories and lots of small files.  Anyway, I suppose if your Internet quality is not bad, this can be a good try.

The idea is to use curlftpfs to mount a directory in an ftp server to a local directory in your harddisk.  Now that you can access files (in ftp) as if they were your local files, you can choose any of your favourite backup tools to sync files in ftp and your local directory.  I use rdiff-backup to create versions of files in ftp in my local harddisk.

See part 2 where I figured out how to sync ftp directory via lftp:

how to sync ftp directory with a local directory in linux [part 2]