CentOS主机备份

2016-06-06 Golmic 更多博文 » 博客 » GitHub »

CentOS

原文链接 http://code.lujq.me/2016/06/06/CentOS%E4%B8%BB%E6%9C%BA%E5%A4%87%E4%BB%BD/
注:以下为加速网络访问所做的原文缓存,经过重新格式化,可能存在格式方面的问题,或偶有遗漏信息,请以原文为准。


CentOS主机备份 <!--more-->

主域名博客备份

文件备份

使用tar -zcvf 1.tar.gz lujq.me命令压缩虚拟主机文件夹,并下载到本地;

数据库备份

phpMyAdmin 备份相应的数据库,下载到本地;

nginx配置备份

server {
    listen 80;
    listen 443 ssl;
    server_name  lujq.me;

    ssl on;
    ssl_certificate /etc/ssl/private/lujq_me.crt;
    ssl_certificate_key /etc/ssl/private/lujq_me.key;
    root   /home/wwwroot/lujq.me/;
    access_log off;
    index index.html index.htm index.php;
    include wordpress.conf;
    ssl_prefer_server_ciphers on;
    ssl_dhparam /etc/ssl/certs/dhparam.pem;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers "EECDH+ECDSA+AESGCM EECDH+aRSA+AESGCM EECDH+ECDSA+SHA384 EECDH+ECDSA+SHA256 EECDH+aRSA+SHA384 EECDH+aRSA+SHA256 EECDH+aRSA+RC4 EECDH EDH+aRSA !aNULL !eNULL !LOW !3DES !MD5 !EXP !PSK !SRP !DSS !RC4";
    keepalive_timeout 70;
    ssl_session_cache shared:SSL:10m;
    ssl_session_timeout 10m;
    add_header Strict-Transport-Security max-age=63072000;
    add_header X-Frame-Options DENY;
    add_header X-Content-Type-Options nosniff;

location ~ .*\.(php|php5)?$ {
    #fastcgi_pass remote_php_ip:9000;
    fastcgi_pass unix:/dev/shm/php-cgi.sock;
    fastcgi_index index.php;
    include fastcgi.conf;
    }
location ~ .*\.(gif|jpg|jpeg|png|pdf|bmp|swf|flv|ico)$ {
    expires 30d;
    access_log off;
    }
location ~ .*\.(js|css)?$ {
    expires 7d;
    access_log off;
    }
}
server {
  server_name  resume.lujq.me;
  root   /home/wwwroot/lujq.me/resume/;
access_log off;
index index.html index.htm index.php;

location ~ .*\.(php|php5)?$ {
    #fastcgi_pass remote_php_ip:9000;
    fastcgi_pass unix:/dev/shm/php-cgi.sock;
    fastcgi_index index.php;
    include fastcgi.conf;
    }
location ~ .*\.(gif|jpg|jpeg|png|pdf|bmp|swf|flv|ico)$ {
    expires 30d;
    access_log off;
    }
location ~ .*\.(js|css)?$ {
    expires 7d;
    access_log off;
    }
}

SSL证书备份

/etc/ssl/private/lujq_me.crt /etc/ssl/private/lujq_me.key /etc/ssl/private/lujq_me.csr/usr/local/nginx/conf/ssl/

Node网站备份

MongoDB备份

mongodump -h dbhost -d dbname -o dbdirectory -h: MongDB所在服务器地址,例如:127.0.0.1,当然也可以指定端口号:127.0.0.1:27017 -d: 需要备份的数据库实例,例如:test -o: 备份的数据存放位置,例如:/opt,当然该目录需要提前建立,在备份完成后,系统自动在/opt目录下建立一个目录,这个目录里面存放该数据库实例的备份数据。

tar -zcvf 1.tar.gz DB压缩并下载到本地。