backing up sd card automatically (linux)

Nov 20, 2016
18
1
I have a hikvision DS-2CD3132F-IWS (firmware V5.2.5), and would like to record on motion detection to the SD card, and then have a nightly script which backs up any video on the SD card to a linux box on the same network.

Recording on motion to the SD card is working. Getting video off the SD card is proving quite difficult. I am not interested in using the web interface. First, it doesn't work on my linux box. Second, I want something I can run from cron to automate the process.

I have been searching for solutions for hours, and have discovered that:

1) It used to be possible to telnet into the camera and use an ftpput command to copy files off of it. This has since been removed. (why?)
2) It also used to be possible to telnet into the camera and start a local ftp server, which would have made it possible to simply ftp into the camera and download the files. This has apparently also been removed. (why?)
3) Someone claimed it was possible to "use the SDK" to do this, but I haven't been able to make much progress figuring out what SDK was being referred to.

Even if I was able to get the files off the SD card to my linux box, they are apparently wrapped up in some proprietary binary format, that I would have to reverse engineer to extract the video files. There are a few github repos laying around which attempt to do this, but apparently the format has changed and some (or all) of these tools don't work anymore.

Am I missing a more straightforward approach to what seems like it ought to be a very easy thing to do? Back up the files from the SD card without a pointy-clicky windows only interface?

Thanks for any help!
 
Am I missing a more straightforward approach to what seems like it ought to be a very easy thing to do? Back up the files from the SD card without a pointy-clicky windows only interface?
I have done this before, as a proof of concept, but I don't have any cameras with an SD card at the moment.
Note that the NetHDD destination does not need to be 'formatted' to copy files to and from it.
However - check out this post, and the later one with the 'plink' suggestion.
Full access to 2732 SD Card files


On 5.2.5 and telnet or SSH - both should still be available.
In the web GUI, check Advanced Configuration | Security | Security service
and enable either / both telnet SSH

Example with 5.2.5:
Code:
alastair@PC-I5 ~ $
alastair@PC-I5 ~ $ ssh root@192.168.254.13
root@192.168.254.13's password:


BusyBox v1.19.3 (2014-07-11 11:25:54 CST) built-in shell (ash)
Enter 'help' for a list of built-in commands.

# prtHardInfo
Start at 2016-11-03 16:01:54
Serial NO :DS-2CD2232-I520150612CCCH524604602
V5.2.5 build 141201
hardwareVersion    = 0x0
hardWareExtVersion    = 0x0
encodeChans        = 1
decodeChans        = 1
alarmInNums        = 0
alarmOutNums        = 0
ataCtrlNums        = 0
flashChipNums        = 0
ramSize            = 0x4000000
networksNums        = 1
language            = 1
devType            = 38919
net reboot count    = 0
SD status            = 0 (1:noraml;0:none)
Path: .
Working Copy Root Path: /data1/data_liwenwei/work/frontend_software_platform_5.2.7_R0
URL: https://192.0.0.140/Camera/Platform/Branches/branches_frontend_software_platform/frontend_software_platform_5.2.7_R0
Repository Root: https://192.0.0.140/Camera
Repository UUID: df2d70c3-7593-7941-af1e-571b313c0946
Revision: 103727
Node Kind: directory
Schedule: normal
Last Changed Author: liwenwei
Last Changed Rev: 103727
Last Changed Date: 2014-12-01 20:51:32 +0800 (Mon, 01 Dec 2014)

#
# mount
rootfs on / type rootfs (rw)
/dev/root on / type ext2 (rw,relatime)
proc on /proc type proc (rw,relatime)
sysfs on /sys type sysfs (rw,relatime)
ramfs on /home type ramfs (rw,relatime)
udev on /dev type tmpfs (rw,relatime)
devpts on /dev/pts type devpts (rw,relatime,mode=600)
/dev/ubi1_0 on /dav type ubifs (rw,relatime)
/dev/ubi3_0 on /davinci type ubifs (rw,relatime)
/dev/ubi4_0 on /config type ubifs (rw,relatime)
192.168.1.201:/cctv1 on /mnt/nfs00 type nfs (rw,sync,relatime,vers=3,rsize=4096,wsize=4096,namlen=255,acregmin=0,acregmax=0,acdirmin=0,acdirmax=0,soft,noac,nolock,proto=tcp,port=65535,timeo=70,retrans=3,sec=sys,local_lock=all,addr=192.168.1.201)
# ls -al /mnt/nfs00
drwxrwxrwx   10 root     root          4096 Nov 20 10:44 .
drwxrwxrwx   13 root     root          1024 Nov 20 10:44 ..
-rwxr-xr-x    1 root     root     130720251 Jul 26 20:31 000005.h264
-rwxr-xr-x    1 root     root        673769 Jul 26 20:32 000010.jpg
-rwxr-xr-x    1 root     root        673926 Jul 26 20:32 000011.jpg
-rwxr-xr-x    1 root     root        673685 Jul 26 20:32 000012.jpg
-rwxr-xr-x    1 root     root        673923 Jul 26 20:32 000013.jpg
-rwxr-xr-x    1 root     root        674075 Jul 26 20:32 000014.jpg
-rwxr-xr-x    1 root     root        676678 Jul 26 20:32 000015.jpg
-rwxr-xr-x    1 root     root        676541 Jul 26 20:32 000016.jpg
-rwxr-xr-x    1 root     root        676757 Jul 26 20:32 000017.jpg
-rwxr-xr-x    1 root     root        676398 Jul 26 20:32 000018.jpg
-rwxr-xr-x    1 root     root        676450 Jul 26 20:32 000019.jpg
drwxrwxrwx    5 root     nogroup       4096 Aug 18 10:41 @Recycle
-rw-rw-rw-    1 65534    nogroup       1104 Jul 26 19:21 S25sdcard.sh
-rwxrwxrwx    1 root     root         10507 Jul 25 21:55 S90ipnc
drwxr-xr-x    3 root     root         12288 Jul  9 15:29 datadir0
drwxr-xr-x    2 root     root         12288 Sep 19  2015 datadir1
drwxr-xr-x    2 root     root         12288 Sep 19  2015 datadir2
-rw-rw-rw-    1 503      100      4294967296 Jul 27 06:16 file1.img
-rw-r--r--    1 root     root            68 Jul 24 22:51 info.bin
-rw-rw-rw-    1 65534    nogroup   14614528 Jul 18 12:04 initrd.image
drwxrwxrwx    3 65534    nogroup       4096 Aug 11 21:17 mtd
-rw-r--r--    1 root     root            23 Jul 26 19:44 resolv.conf
-rw-r--r--    1 root     root          2650 Jul 26 16:37 sdcard.log
drwxrwxrwx   11 root     root         12288 Aug 14 20:37 temp
drwxrwxrwx    2 65534    nogroup       4096 Nov  3 15:47 tmp
d---------    2 root     root          4096 Mar 31  2016 tnfs01
#
 
I am not interested in using the web interface. First, it doesn't work on my linux box.
Not that I use it for Live View - but both the VLC and Quicktime (and MJPEG but forget that ...) plugins work OK under Firefox on my Linux Mint box for the Hikvision cameras.
Though not for the NVRs - I resort to a VM Windows under Oracle VM Virtualbox (free) for that and other Windows requirements.
 
I have done this before, as a proof of concept, but I don't have any cameras with an SD card at the moment.
Note that the NetHDD destination does not need to be 'formatted' to copy files to and from it.
However - check out this post, and the later one with the 'plink' suggestion.
Full access to 2732 SD Card files

Yes, that does seem like it could be made to work, thank you!

On 5.2.5 and telnet or SSH - both should still be available.

Yes, those are still available. It was the "and then use the ftpput command" and "and then start the ftp server" capabilities that used to be available but have been removed.
 
I got this worked out via the http API. It is possible to search the files on the SD card using a search query, and then send download commands to transfer any files matching the query.

The document which can be found by googling "how to integrate storage function of hikvision IP" is very useful, but didn't quite get me there alone. After using wireshark while running the web interface to get some details ironed out, I was able to make it work. Search my recent posts for a working example. The downloading part worked first try in following the howto once I got the search working.
 
Last edited:
  • Like
Reactions: alastairstevenson