联系我们:416326801#qq.com(#改成@)

Latest from the blog

PHP导入Excel时间格式转换

标签: PHP Excel

public static function excelTime($date, $time=false){
        if(is_numeric($date)) {
                $jd = GregorianToJD(1, 1, 1970);
                $gregorian = JDToGregorian($jd+intval($date)-25569);
                $date = explode('/',$gregorian);
                $date_str = str_pad($date[2],4,'0', STR_PAD_LEFT)
                ."-".str_pad($date[0],2,'0', STR_PAD_LEFT)
                ."-".str_pad($date[1],2,'0', STR_PAD_LEFT)
                .($time?" 00:00:00":'');
                return $date_str;
        }
        return $date;
}

MySQL数据库备份脚本

标签: 备份 MySQL Shell Linux

#!/bin/sh
cd /home/backups/sql/
mkdir /home/backups/extmail
 
# Remove old backups
find /home/backups/sql/* -mtime +5 -exec rm -fr {} \; > /dev/null 2>&1
 
# Create the filename for the backup
eval `date "+day=%d; month=%m; year=%Y; hour=%H; min=%M; sec=%S"`
INSTFIL="extmail-backup-$year$month$day-$hour$min$sec"
 
# Dump the MySQL Database
#touch /home/backups/extmail/$INSTFIL.txt
/usr/local/bin/mysqldump -usqlback -p"sqlbackup" --opt extmail > /home/backups/extmail/$INSTFIL.sql
 
# Gzip the whole folder
 
tar -Pcpzf /home/backups/sql/$INSTFIL.tar.gz /home/backups/extmail/*
 
# Remove the SQL Dump
rm -rf /home/backups/extmail

备份Mysql并上传到ftp服务器

标签: 备份 MySQL Shell Linux

#!/bin/bash

#MySQL设置
MysqlHost=localhost
MysqlUser=root
MysqlPwd=password

#备份文件设置
BackupPath=/backup/db
FileName=$MysqlHost-$(date +%Y%m%d-%H%M%S)
FileFullPath=$BackupPath/$FileName

#ftp设置
FtpHost=10.206.4.121
FtpUser=iptv
FtpPwd=StarIptv
FtpPath=/ftp/backup/mysql

mkdir -p $BackupPath

#备份mysql并导出到文件
mysqldump -u$MysqlUser -p$MysqlPwd -h$MysqlHost --opt --all-databases -f > $FileFullPath.sql

#压缩备份文件
tar -Pzcvf $FileFullPath.tar.gz $FileFullPath.sql

#上传到ftp
ftp -n $FtpHost <<AUTOEOF
quote USER $FtpUser
quote PASS $FtpPwd
cd $FtpPath
binary
put $FileFullPath.tar.gz $FtpPath/$FileName.tar.gz
quit
AUTOEOF

#删除SQL文件
rm -rf $FileFullPath.sql

#删除30天之前的文件
find $BackupPath -type f -mtime +30 -exec rm -f {} \;

«« First 12 13 14 15 16 17