Gmail 1
Gmail 1
Gmail 1
1 mensaje
Omar E. Vsquez Chavarri <omar.vasquez.chavarri@gmail.com>
Para: Omar Eduardo Vasquez Chavarri <omar.vasquez.chavarri@gmail.com>
#Backup
script for
Wordpress
installation
#Dependencies: Powershell 2.0+ (required) 7zip (optional), SMTP server without authentication
(optional)
#Author: Tobias Jrvelv - @jarvelov
#Author homepage: tobias.jarvelov.se
#Last updated: 2016-03-02
## Config Start ##
#Credentials
$mysqlUser = "user"
#Mysql username
$mysqlPass = "pass"
#Mysql password
#Filepaths
$sourceDir = "WPINSTALLDIR"
#e.g. C:\inetpub\wwwroot
Files\7zip\7za.exe"'
#Settings
$mailEnabled = $True
$zipEnabled = $True
$smtpPort = 25
#Output directory name format
$prefix = "wpbackup_"
$date = (Get-Date -Format "yyyy_MM_dd_HHmm").ToString()
## Config End ##
#No need to configure anything below this line"
## Functions ##
Function Write-Log ($msg){
$logDate = (Get-Date -Format "yyyy_MM_dd_HHmm").ToString()
$content = "$logDate : $msg"
Write-Host $content
Add-Content -Value $content -Path $logFile
}
## Program Start ##
#Create log and temporary folder
$name = "Create folders"
$logDir =".\logs\"
$logFile = "$logDir$prefix$date.txt"
$tmpName = "$prefix$date"
$tmpDir = ".\$tmpName"
$steps = @()
Try {
If((Test-Path ($logDir)) -eq $false) {
New-Item -ItemType Directory -Path $logDir | Out-Null
}
Write-Log "Info $name : Creating log and temporary directories."
#Make sure $tmpDir exists
If((Test-Path ($tmpDir)) -eq $false) {
New-Item -ItemType Directory -Path $tmpDir | Out-Null
}
#Make sure $destDir exists
If((Test-Path ($destDir)) -eq $false) {
New-Item -ItemType Directory -Path $destDir | Out-Null
}
$status = $true
} Catch [Exception] {
Write-Log "Failure $name : Could not create temporary directories. Exception:
"$_.Exception.Message
$status = $false
}
$steps += @($status,$name)
#Copy Wordpress installation
$name = "Copy files"
Write-Log "Info $name : Copying Wordpress directory..."
Try {
Copy-Item -Path $sourceDir -Recurse -Destination "$tmpDir"
#If copy is done but tmpDir isn't created, report failure
...