- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
WordPress 中有多个站点。 backup buddy plugin 使用配置好的 amazon S3 bucket 我们需要每周发送邮件 在所有站点备份信息中是否收到最近的备份。
最佳答案
终于找到答案了
首先安装 AWS S3 包引用这个'https://docs.aws.amazon.com/sdk-for-php/v3/developer-guide/s3-examples-creating-buckets.html '然后下面提到的代码创建 index.php 文件然后在浏览器中调用工作正常
当你想自动运行 index.php 文件时使用 cron
require 'vendor/autoload.php';
use Aws\S3\S3Client;
use Aws\Exception\AwsException;
$bucketData = '{
"bucket":{
"1":{
"name":"bucketname-1",
"backup":"backups/"
},
"2":{
"name":"bucketname-2",
"backup":"backups/"
}
},
"uncheck":[
"menardsimages"
]
}';
//multile-bucket-having-mentioned-except'uncheck'
$bucketData = json_decode($bucketData);
/**
* List your Amazon S3 buckets.
*
* This code expects that you have AWS credentials set up per:
* https://docs.aws.amazon.com/sdk-for-php/v3/developer-guide/guide_credentials.html
*/
$key = 'xxxxxxxxx';
$secret = 'yyyyyyyy';
//Create a S3Client
$s3Client = new S3Client([
'region' => 'us-west-2',
'version' => 'latest',
'credentials' => [
'key' => $key,
'secret' => $secret,
]
]);
function recent_backup_verify($objects){
$tendays_bf_today = date('Y-m-d',(strtotime ( '-7 day' , strtotime ( date("Y-m-d")) ) ));
foreach ($objects as $object) {
$created_date = $object['LastModified']->format('Y-m-d');
if($created_date > $tendays_bf_today){
return $created_date;
}
}
return false;
}
function searchForName($name, $array) {
foreach ($array as $key => $val) {
if ($val->name === $name) {
return $val->backup;
}
}
return null;
}
$buckets = $s3Client->listBuckets();
//print_r($created_bucketlist);
$backup_array = array();
foreach ($buckets['Buckets'] as $bucket) {
//files-listing-insideofthe-bucket
if(!in_array($bucket['Name'], $bucketData->uncheck)){
$objects = $s3Client->getIterator('ListObjects', array(
"Bucket" => $bucket['Name'],
"Prefix" => searchForName($bucket['Name'], $bucketData->bucket) //must have the trailing forward slash "/"
));
$getbackup_result = recent_backup_verify($objects);
if($getbackup_result != false){
$backup_array[$bucket['Name']]['status'] = 'Taken';
$backup_array[$bucket['Name']]['date'] = $getbackup_result;
}else{
$backup_array[$bucket['Name']]['status'] = 'Not Taken';
$backup_array[$bucket['Name']]['date'] = '-';
}
}
}
sendgrid_form($backup_array);
function sendgrid_form($backup_array){
$msg = '<table border="1" cellpadding="5" cellspacing="0" width="500px" style="border-color:#ddd;">';
$msg .= '<tr bgcolor="#555" style="color:#fff;">';
$msg .= '<th>S.No</th><th>Site Name</th><th width="100px">Backup Date</th><th width="100px">Backup Status</th>';
$msg .= '</tr>';
$s_no = 1;
foreach($backup_array as $site=>$val){
if($val['status'] == 'Taken'){$color = 'green';}else{$color='red';}
$msg .= '<tr>';
$msg .= '<td align="center">'.$s_no.'</td><td>'.$site.'</td><td align="center" >'.$val['date'].'</td><td align="center" style="color:'.$color.'">'.$val['status'].'</td>';
$msg .= '</tr>';
$s_no++;
}
$msg .= '</table>';
$message_html = "<hr width='20%' align='left'>
<img src='logo.png' width='100px'>
<hr width='20%' align='left'>
<h3>Hi Team,</h3>
<p>This is the list that has the every week backup status of our websites/applications that received in our AWS S3. If the 'Backup Status' is 'Not Taken' please check with the script/plugin immediately.</p>
".$msg."
<p>Thank You</p>";
$to = 'reciever@example.com';
$json_string = array(
'to' => array($to),
'category' => 's3_backup'
);
$params = array(
'api_user' => 'xxxxx',
'api_key' => 'yyyy',
'x-smtpapi' => json_encode($json_string),
'to' => $to,
'subject' => 'Backup S3 Report!',
'html' => $message_html,
'from' => 'info@example.com',
);
$request = 'https://api.sendgrid.com/api/mail.send.json';
$session = curl_init($request);
curl_setopt ($session, CURLOPT_POST, true);
curl_setopt ($session, CURLOPT_POSTFIELDS, $params);
curl_setopt($session, CURLOPT_HEADER, false);
curl_setopt($session, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($session);
curl_close($session);
$temp = json_decode($response);
if($temp->message == 'success'){
$data['success'] = "Email Send Successfully!";
}else{
$data['success'] = "Email Send Failed!";
}
echo json_encode($data);
}
关于php - 如何在 WordPress 备份后每周发送邮件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60126836/
如何启用 Mercurial(中央/主)存储库的自动(增量)备份? 我来自颠覆,在那里我能够制作一个提交 Hook ,将更改上传到 S3。 编辑: 如果这种策略对 Mercurial 没有意义,那么什
我想定期创建我的github存储库的备份。是否有一种快速的方法可以在不知道整个列表的情况下将它们全部拉出? 沃尔特 最佳答案 您可以通过GitHub的API获取整个列表: curl http://gi
我正在使用 flatpages在我在本地服务器上开发的站点中。我需要备份平面页面的数据以在最终服务器中使用它。有谁知道怎么做? 最佳答案 在您的本地服务器上运行: python manage.py d
我们已将应用服务升级到 S1,并希望设置自动备份。这是一个带有 SQL 数据库的 .net core 应用程序。对于数据库部分,我得到以下内容: No supported connection str
我们使用一些 阻止 blob 来存储一些持久资源,然后 用于存储事件数据的页面 blob 我们需要备份 blob,因此我尝试使用 AzCopy。它在我的开发机器上工作正常,但在其他慢速机器上失败,并出
关闭。这个问题需要更多 focused .它目前不接受答案。 想改进这个问题?更新问题,使其仅关注一个问题 editing this post . 5年前关闭。 Improve this questi
我正在看这个例子 docker run --rm --volumes-from myredis -v $(pwd)/backup:/backup debian cp /data/dump.rdb /b
我们使用一些 阻止 blob 来存储一些持久资源,然后 用于存储事件数据的页面 blob 我们需要备份 blob,因此我尝试使用 AzCopy。它在我的开发机器上工作正常,但在其他慢速机器上失败,并出
我目前正在使用 Java,并且正在寻找一个程序,该程序可以在每次编译时保存我正在执行的操作的新版本。我不介意它是否不运行,我可以进去编辑类名,使其与 .java 名称匹配。由于我是一个初学者,我总是因
在 RabbitMQ 管理控制台中,出于导入和导出目的,我在概览页面底部看到了导入/导出定义链接。但是有了这个,我能够导出整套队列、交换等。 我有一个 MQ 服务器,其中包含多个应用程序的 MQ 设置
我在 Eclipse IDE 中做了一个 Maven 项目,但在某些时候,我决定以其他名称复制并粘贴工作区位置中的文件夹,以避免在迄今为止工作正常的原始项目中进行一些错误配置,但是,我在执行中遇到了问
有没有办法备份在任何给定元素上设置的所有事件? 背景故事:我有一些代码,当用户将鼠标悬停在某个图标上时(想想悬停帮助文本),会显示绝对定位的“弹出窗口”。如果用户将鼠标悬停在弹出窗口上,它会停留在周围
我需要将 MySQL 数据库移动到新位置。根据workbench,数据库大小只有200MB,但有些表有数百万行,报告索引和数GB的数据长度。结果,EXPORT 的大小为 15GB,导出 DB 并将其复
我有一个工作数据库 - 我想复制它的所有数据(甚至只是其中的 1 个表)并在磁盘上创建备份,并在另一个位置(不是同一台计算机)上创建一个“备份”数据库。另一台计算机未连接到互联网 我该怎么做? 最佳答
我有一个实时数据库,我想要做的是制作一份副本。我可以通过 SSH 和 phpMyAdmin 访问 MySQl。是否有一个命令可以在单个命令/操作中复制/备份数据库,而无需使用导出/导入? 谢谢 最佳答
我是 PostgreSQL 的新手,我正在寻找备份数据库的方法。我知道有 3 种方法 pg_dump,快照和复制以及使用 WAL。您建议使用哪一个来完整备份数据库?如果可能,请提供代码片段。 最佳答案
如何快速备份/恢复mysql数据库中的数据? 最佳答案 mysqldump命令行备份最快, (使用mysql命令行恢复,mysql -u #username# -p #database# < #dum
从管理的角度来看,我是 MySQL 的新手。 在过去的几个小时里,我一直在谷歌上搜索,但没有成功,我想知道是否有人可以为我指明正确的方向,让我知道要用谷歌搜索什么或提出建议。 基本上,我正在寻找有关如
我需要备份创建模式附带的数据库(转储)。使用 putty(通过 SSH)完成这项工作的命令行是什么?我研究并思考了这个命令,但它只执行表备份和数据。 mysqldump -h HOST -u LOGI
我正在尝试创建一个将整个/dev/sda1 备份到/mnt/Backup 的 bash 脚本 /dev/sda1 457G 3.5G 431G 1% / /dev/sdb1
我是一名优秀的程序员,十分优秀!