Home Database Mysql Tutorial 自动备份和下载WordPress(及MySQL)的fabric脚本_MySQL

自动备份和下载WordPress(及MySQL)的fabric脚本_MySQL

Jun 01, 2016 pm 01:15 PM
fabric wordpress database server

WordPress

在一年多之前,我写过一个博客介绍Fabric(Fabric 一个与多台服务器远程交互的Python库和工具),前段时间我也在项目中也大量使用了Fabric来管理很多服务器。
我的博客搭建在一个KVM VPS上,今天也写了一个fabfile来dump数据库、打包WordPress目录,并下载到本地。fabfile代码如下:

#!/usr/bin/python# use Fabric to manage all the hosts in perf env.# usage: fab -f vps_fabfile.py download_backup# author: Jay <smile665> from fabric.context_managers import cd#from fabric.context_managers import settingsfrom fabric.operations import *from fabric.api import *from datetime import datetime env.hosts = 'smilejay.com'env.port = 22env.user = 'root'env.password = '1234'@taskdef download_backup():	# backup my WP file and database, download them to the local machine	dt = datetime.now().strftime("%Y-%m-%d-%H-%M-%S")	local_dir = '/home/jay/backup'	with cd('/tmp'):		nginx = '/usr/share/nginx'		wp_root = '/usr/share/nginx/html'		exclude = 'html/wp-content/cache'		bk_name = 'wp_%s.tar.gz' % dt		clean = 'rm -f wp*.tar.gz'		mysql = 'mysqldump -uroot -p1234 -A > %s/mysql-dump.sql' % wp_root		tar = 'tar -zcf %s -C %s html --exclude=%s' % (bk_name, nginx, exclude)		run(clean)		run(mysql)		run(tar)		get(bk_name, '%s/%s' % (local_dir, bk_name))</smile665>
Copy after login

Github地址:https://github.com/smilejay/python/blob/master/py2014/vps_fabfile.py
当然,我一般也会使用BackWPup插件来备份WordPress;刚好发现,前段时间使用Nginx替代Apache后,BackWPup运行时仍然要写“/var/www/html/wp-content/backwpup-logs/”目录,所以有个权限问题,最近两个月都是运行失败了。后来对这个目录开放了写权限就没问题了。

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP vs. Flutter: The best choice for mobile development PHP vs. Flutter: The best choice for mobile development May 06, 2024 pm 10:45 PM

PHP and Flutter are popular technologies for mobile development. Flutter excels in cross-platform capabilities, performance and user interface, and is suitable for applications that require high performance, cross-platform and customized UI. PHP is suitable for server-side applications with lower performance and not cross-platform.

Does wordpress need to be registered? Does wordpress need to be registered? Apr 16, 2024 pm 12:07 PM

WordPress requires registration. According to my country's "Internet Security Management Measures", websites that provide Internet information services within the country must register with the local provincial Internet Information Office, including WordPress. The registration process includes steps such as selecting a service provider, preparing information, submitting an application, reviewing and publishing, and obtaining a registration number. The benefits of filing include legal compliance, improving credibility, meeting access requirements, ensuring normal access, etc. The filing information must be true and valid, and must be updated regularly after filing.

Detailed tutorial on establishing a database connection using MySQLi in PHP Detailed tutorial on establishing a database connection using MySQLi in PHP Jun 04, 2024 pm 01:42 PM

How to use MySQLi to establish a database connection in PHP: Include MySQLi extension (require_once) Create connection function (functionconnect_to_db) Call connection function ($conn=connect_to_db()) Execute query ($result=$conn->query()) Close connection ( $conn->close())

How does Hibernate implement polymorphic mapping? How does Hibernate implement polymorphic mapping? Apr 17, 2024 pm 12:09 PM

Hibernate polymorphic mapping can map inherited classes to the database and provides the following mapping types: joined-subclass: Create a separate table for the subclass, including all columns of the parent class. table-per-class: Create a separate table for subclasses, containing only subclass-specific columns. union-subclass: similar to joined-subclass, but the parent class table unions all subclass columns.

What is the wordpress article database? What is the wordpress article database? Apr 16, 2024 am 11:12 AM

WordPress uses MySQL as its article database, its main functions include: storing articles, comments, users and website configuration data. The data tables include: wp_posts (articles), wp_postmeta (metadata), wp_comments (comments), wp_commentmeta (comment metadata), wp_users (users). The database can be accessed and managed via phpMyAdmin or the command line, and it is crucial to back up the database regularly to prevent data loss.

iOS 18 adds a new 'Recovered' album function to retrieve lost or damaged photos iOS 18 adds a new 'Recovered' album function to retrieve lost or damaged photos Jul 18, 2024 am 05:48 AM

Apple's latest releases of iOS18, iPadOS18 and macOS Sequoia systems have added an important feature to the Photos application, designed to help users easily recover photos and videos lost or damaged due to various reasons. The new feature introduces an album called "Recovered" in the Tools section of the Photos app that will automatically appear when a user has pictures or videos on their device that are not part of their photo library. The emergence of the "Recovered" album provides a solution for photos and videos lost due to database corruption, the camera application not saving to the photo library correctly, or a third-party application managing the photo library. Users only need a few simple steps

where is wordpress search where is wordpress search Apr 16, 2024 am 11:09 AM

WordPress search functionality provides users with the convenience of finding content quickly: Location: In the header or top menu Features: Full text search, keyword matching, relevance sorting, fuzzy search Advanced options: Category restrictions, author restrictions, date range, format restrictions Customization: Customize number of results, summary length, matching keyword highlighting

Does wordpress require code? Does wordpress require code? Apr 16, 2024 pm 12:00 PM

Yes, WordPress is a CMS that allows users to manage websites without coding. However, advanced features and customizations may require some coding knowledge, including themes, plugins, widgets, custom post types, and functions. Code level requirements vary depending on the goals of the implementation, typically no code is required for basic functionality, but basics of HTML, CSS, and PHP are required for advanced customization.

See all articles