• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2517
  • Last Modified:

command/script to do "dd/dump" piped into an ftp server

I have 2 versions of ESX (2.5 & 3.5) which I thought of taking a dd/dump (let me know which one is
a better option for recovery in case the movers damaged our disks during the relocation
tomorrow) :

On ESX V3.5 :
# df -k
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/cciss/c0d0p2      5036316   1346272   3434212  29% /
/dev/cciss/c0d0p1       101089     26276     69594  28% /boot
none                    134284         0    134284   0% /dev/shm
/dev/cciss/c0d0p6      2008108    124408   1781692   7% /var/log

# fdisk -l

Disk /dev/sda: 75.1 GB, 75169267712 bytes
255 heads, 63 sectors/track, 9138 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot    Start       End    Blocks   Id  System
/dev/sda1             1      9138  73400921   fb  Unknown

Disk /dev/sdb: 102.0 GB, 102015959040 bytes
255 heads, 63 sectors/track, 12402 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot    Start       End    Blocks   Id  System
/dev/sdb1             1     11749  94373778+  fb  Unknown

Disk /dev/sdc: 85.9 GB, 85905637376 bytes
255 heads, 63 sectors/track, 10444 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot    Start       End    Blocks   Id  System
/dev/sdc1             1     10444  83891366   fb  Unknown

Disk /dev/cciss/c0d0: 146.7 GB, 146778685440 bytes
255 heads, 63 sectors/track, 17844 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

           Device Boot    Start       End    Blocks   Id  System
/dev/cciss/c0d0p1   *         1        13    104391   83  Linux
/dev/cciss/c0d0p2            14       650   5116702+  83  Linux
/dev/cciss/c0d0p3           651     17508 135411885   fb  Unknown
/dev/cciss/c0d0p4         17509     17844   2698920    f  Win95 Ext'd (LBA)
/dev/cciss/c0d0p5         17509     17577    554211   82  Linux swap
/dev/cciss/c0d0p6         17578     17831   2040223+  83  Linux
/dev/cciss/c0d0p7         17832     17844    104391   fc  Unknown


On ESX 2.5 :

# df -k
Filesystem           1k-blocks      Used Available Use% Mounted on
/dev/cciss/c0d0p5      2522048   1629044    764888  69% /
/dev/cciss/c0d0p1        46636     17931     26297  41% /boot
/dev/cciss/c0d0p8       295564     66101    214203  24% /home
none                    192280         0    192280   0% /dev/shm
/dev/cciss/c0d0p6      2016016    360776   1552828  19% /var
/dev/cciss/c0d0p2     10080520     32828   9535624   1% /vmimages

# fdisk -l

Disk /dev/sda: 255 heads, 63 sectors, 30024 cylinders
Units = cylinders of 16065 * 512 bytes

   Device Boot    Start       End    Blocks   Id  System
/dev/sda1             1     30024 241167748+  fb  Unknown

Disk /dev/sdb: 64 heads, 32 sectors, 12308 cylinders
Units = cylinders of 2048 * 512 bytes

   Device Boot    Start       End    Blocks   Id  System
/dev/sdb1             1     12308  12603376   fb  Unknown

Disk /dev/sdc: 64 heads, 32 sectors, 57348 cylinders
Units = cylinders of 2048 * 512 bytes

   Device Boot    Start       End    Blocks   Id  System
/dev/sdc1             1     57348  58724336   fb  Unknown

Disk /dev/sdd: 255 heads, 63 sectors, 33940 cylinders
Units = cylinders of 16065 * 512 bytes

   Device Boot    Start       End    Blocks   Id  System
/dev/sdd1             1     33940 272623018+  fb  Unknown

Disk /dev/sde: 64 heads, 32 sectors, 56835 cylinders
Units = cylinders of 2048 * 512 bytes

   Device Boot    Start       End    Blocks   Id  System
/dev/sde1             1     56835  58199024   fb  Unknown

Disk /dev/sdf: 255 heads, 63 sectors, 32635 cylinders
Units = cylinders of 16065 * 512 bytes

   Device Boot    Start       End    Blocks   Id  System
/dev/sdf1             1     32635 262140606   fb  Unknown

Disk /dev/sdg: 255 heads, 63 sectors, 20888 cylinders
Units = cylinders of 16065 * 512 bytes

   Device Boot    Start       End    Blocks   Id  System
/dev/sdg1             1     20888 167782828+  fb  Unknown

Disk /dev/sdh: 255 heads, 63 sectors, 33418 cylinders
Units = cylinders of 16065 * 512 bytes

   Device Boot    Start       End    Blocks   Id  System
/dev/sdh1             1     33418 268430053+  fb  Unknown

Disk /dev/sdi: 255 heads, 63 sectors, 15666 cylinders
Units = cylinders of 16065 * 512 bytes

   Device Boot    Start       End    Blocks   Id  System
/dev/sdi1             1     15666 125837113+  fb  Unknown

Disk /dev/sdj: 64 heads, 32 sectors, 56322 cylinders
Units = cylinders of 2048 * 512 bytes

   Device Boot    Start       End    Blocks   Id  System
/dev/sdj1             1     56322  57673712   fb  Unknown

Disk /dev/sdk: 64 heads, 32 sectors, 20480 cylinders
Units = cylinders of 2048 * 512 bytes

   Device Boot    Start       End    Blocks   Id  System
/dev/sdk1             1     20480  20971504   fb  Unknown

Disk /dev/sdl: 255 heads, 63 sectors, 26108 cylinders
Units = cylinders of 16065 * 512 bytes

   Device Boot    Start       End    Blocks   Id  System
/dev/sdl1             1     26108 209712478+  fb  Unknown

Disk /dev/cciss/c0d0: 255 heads, 63 sectors, 17848 cylinders
Units = cylinders of 16065 * 512 bytes

           Device Boot    Start       End    Blocks   Id  System
/dev/cciss/c0d0p1   *         1         6     48163+  83  Linux
/dev/cciss/c0d0p2             7      1281  10241437+  83  Linux
/dev/cciss/c0d0p3          1282     17032 126519907+  fb  Unknown
/dev/cciss/c0d0p4         17033     17848   6554520    f  Win95 Ext'd (LBA)
/dev/cciss/c0d0p5         17033     17351   2562336   83  Linux
/dev/cciss/c0d0p6         17352     17606   2048256   83  Linux
/dev/cciss/c0d0p7         17607     17797   1534176   82  Linux swap
/dev/cciss/c0d0p8         17798     17835    305203+  83  Linux
/dev/cciss/c0d0p9         17836     17848    104391   fc  Unknown


Cant do 'dump+ssh' (ufsdump 0uf - /  | ssh remote_user@remote_svr "cd /bk; cat > svr1.dmp"
for some reason (think it's the firewall in the ESX or the blade switch) but I'm able to ftp to an
 external ftp server.

Kindly give me the dump+ftp  or  dd+ftp so that I could dump/dd the above partitions out
to an ftp server.  I 'think' I have the VMware media around somewhere but just in case I
don't have the correct version of media, thought I'll need a dd or dump
0
sunhux
Asked:
sunhux
  • 2
  • 2
2 Solutions
 
dainokCommented:
Shutdown all VM and backup (tar) /vmfs/volumes/. If you can't shutdown them, snapshot them and backup /vmfs/volumes/.

I attach you a script I wrote few months ago, maybe you can adapt it. The script, invoked by my backup software, simply create a snapshot before the backup, and delete it when the backup finish.
Remember, you can't save delta.vmdk files, because they're in use byt he powered on VM.

VM files:
ubuntu.vmx - VM configuration
ubuntu.nvram - NVRAM
ubuntu.vmsd - snapshot information
ubuntu.vmdk - first disk (geometry)
ubuntu-flat.vmdk - first disk (data)
ubuntu-000001.vmdk - first snapshot of first disk (geometry information) Don't backup!
ubuntu-000001-delta.vmdk - first snapshot of first disk (data) Don't backup

If you lose your content, restore the backup and edit the vmx file: delete all snapshot information and make disk point to the real disk instead the snapshot.
#!/bin/bash
 
usage() {
        echo "Usage: $0 <vmguest> <start|stop>"
        exit 1
}
action() {
        VMCONF=$(vmware-cmd -l | grep "/$VMNAME/")
        if [ $? == 1 ]; then
                echo "Guest VM not found"
                exit 1
        fi
        STATE=$(vmware-cmd -q $VMCONF getstate)
        HASSNAPSHOT=$(vmware-cmd -q $VMCONF hassnapshot)
        DATE=$(date +%Y%m%d)
        echo "VMNAME:   $VMNAME"
        echo "STATE:    $STATE"
        echo "SNAPSHOT: $HASSNAPSHOT"
        echo "ACTION:   $ACTION backup"
        if [ "$STATE" == 'on' ]; then
                if [ "$ACTION" == 'start' ]; then
                        vmware-cmd "$VMCONF" createsnapshot backup-$DATE "Snatpshot created for backup on $DATE" 0 0
                        if [ $? == 0 ]; then
                                echo "Created snapshot, going ahead"
                        else
                                echo "Failed to create snapshot, stopping"
                                exit 1
                        fi
                else
                        vmware-cmd "$VMCONF" removesnapshots
                        if [ $? == 0 ]; then
                                echo "Removed snapshot, going ahead"
                        else
                                echo "Failed to remove snapshot, stopping"
                                exit 1
                        fi
                fi
        else
                if [ "$ACTION" == 'start' ]; then
                        echo "Guest VM $VMNAME is powered off, going ahead"
                else
                        echo "Guest VM $VMNAME is powered off, going ahead"
                fi
        fi
}
 
 
VMNAME="$1"
ACTION="$2"
 
case "$ACTION" in
start)
        action
;;
stop)
        action
;;
*)
        usage
;;
esac
 
exit 0

Open in new window

0
 
sunhuxAuthor Commented:
Thanks, that's a lot of effort you've put in.

What I need is simply the command syntax to combine  "dd" with "ftp" using
pipe & redirection where applicable.  Something like the sample command below
but I just can't get the syntax right :
 # dd if=/dev/sda1 - | ftp 10.51.6.104 "of=output.dmp"
 ftp: 10.51.6.104 of=output.dmp: Servname not supported for ai_socktype
 dd: unrecognized option `-'


0
 
sunhuxAuthor Commented:
The aim is to take a dump or dd & save into a remote ftp server's tape drive/disk
0
 
dainokCommented:
I dont' think dd is a good solution; ESX uses a proprietary filesystem and I can't assure you could properly restore your data. Moreover, using dd you have to copy the whole filesystem, using tar you can copy relevant data only.
0

Featured Post

NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now