zoukankan      html  css  js  c++  java
  • Linux wget auto login and backup database

    #!/bin/bash
    
    # 这是一份本来打算采用自动备份数据的代码,由于测试过程中出现了无法连接的问题,导致不能测试,
    # 于是最后放弃了这份代码的进一步的开发,但是记录还是有必要的
    
    login_url='xxxxxxxxx:2083/login/?login_only=1'
    cookie_file='cookie'
    login_params="--save-cookies $cookie_file --keep-session-cookies --post-data='user=z&pass=q' --referer='xxxxxxxx:2083/' --no-check-certificate"
    download_params="--save-cookies $cookie_file --keep-session-cookies --load-cookies $cookie_file --referer='xxxxxxx:2083/{{SESSION_ID}}/frontend/paper_lantern/backup/index.html' --no-check-certificate"
    backup_url='xxxxxxxx/{{SESSION_ID}}/getsqlbackup/z_zengjf.sql.gz'
    
    login() {
        wget $login_params "$login_url" -O -
        exit
        #return_html=$(wget $login_params "$login_url 2> /dev/null" -O -)
        session_id=$(echo "$return_html" | awk -F/ '{print $2}')
    }
    
    download() {
        url=$(echo "$backup_url" | sed -r "s/{{SESSION_ID}}/$session_id/")
        params=$(echo "$download_params" | sed -r "s/{{SESSION_ID}}/$session_id/")
        file_name="blog_db_$(date +'%Y%m%d%H%M%S').sql.gz"
        wget $params "$url" -O $file_name
    }
    
    clean() {
        rm -f $cookie_file
    }
    
    login
    #download
    #clean
  • 相关阅读:
    JQuery中$.ajax()方法参数详解
    overload和override的区别
    linux 安装jdk和tomcat
    linux链接外网手动设置
    RISC与CISCCPU构架
    32位与64位内存区别
    system 系统调用、gcc编译过程
    c helloworld
    C语言中 有符号数、无符号数、整数溢出 (转)
    samba安装
  • 原文地址:https://www.cnblogs.com/zengjfgit/p/4909773.html
Copyright © 2011-2022 走看看