allwinner-midware/app/InitScript/common/backuplocalfiles.sh

43 lines
1.2 KiB
Bash
Executable File

#!/bin/sh
CC_GO_LOG="/tmp/cc_go.log"
rm -f $CC_GO_LOG
if [ "$1" == "backup" ]; then
ROOTDIR="/mnt/UDISK"
outfile="$ROOTDIR/backuplog_nand.tar.gz"
else
ROOTDIR="/tmp"
outfile="$ROOTDIR/backuplog.tar.gz"
fi
backupfiles="/tmp/*.log /tmp/glog /etc/openwrt_release /etc/openwrt_version /mnt/UDISK/wifi/ /mnt/UDISK/bt/ /mnt/UDISK/*.db"
size=`du -c $backupfiles | tail -n 1 | awk '{print $1;}'`
echo $size
if [ -f $outfile ]; then
rm $outfile
fi
if [ "$size" -gt "15120" ]
then
echo "size larger than the limit, do nothing!!"
else
echo "size smaller the limit, begin to backup files!"
dmesg > /tmp/dmesg.log
top -n 1 -b > /tmp/sysinfo.log
echo "dump debug/pprof/goroutine?debug=1" >> $CC_GO_LOG
curl http://127.0.0.1:1705/debug/pprof/goroutine?debug=1 >> $CC_GO_LOG
echo "dump debug/pprof/goroutine?debug=2" >> $CC_GO_LOG
curl http://127.0.0.1:1705/debug/pprof/goroutine?debug=2 >> $CC_GO_LOG
echo "dump debug/pprof/heap?debug=1" >> $CC_GO_LOG
curl http://127.0.0.1:1705/debug/pprof/heap?debug=1 >> $CC_GO_LOG
echo "dump test/mcust" >> $CC_GO_LOG
curl http://127.0.0.1:1705/pvt/test/mcust >> $CC_GO_LOG
tar -zcvf $outfile $backupfiles
sync
fi