简体   繁体   English

将文件从S3中复制到Ubuntu 18.04中的临时文件夹的计划过程

[英]Scheduled process to copy files out of S3 into a temp-folder in Ubuntu 18.04

Looking for recommendations for the following scenario: 在以下情况下寻找建议:

In an ubuntu 18.04 server, every 1 minute check for new files in an AWS S3 bucket, fetch only the newest file to a temp folder at the end of the day remove them. 在ubuntu 18.04服务器中,每隔1分钟检查一次AWS S3存储桶中的新文件,一天结束时仅将最新文件提取到temp文件夹中。

It should be automated in bash. 它应该在bash中自动执行。

I proposed using aws s3 events notification, queues, lambda but it was defined that is best to keep it simple. 我建议使用aws s3事件通知,队列,lambda,但定义它最好是使其保持简单。

i am looking for recommendations for the steps described below: 我正在寻找以下步骤的建议:

For step 1 i was doing aws s3 ls | awk (FUNCTION to filter files updated within the last minute) 对于步骤1,我正在做aws s3 ls | awk (FUNCTION to filter files updated within the last minute) aws s3 ls | awk (FUNCTION to filter files updated within the last minute) then i realized that it was best to do it with grep aws s3 ls | awk (FUNCTION to filter files updated within the last minute)然后我意识到最好使用grep

 0-Cron job should run from 7:00 to 23:00 every minute 1-List the files updated to S3 bucket during the past 1 minute 2-List the files in a temp-encrypted folder in ubuntu 18.03 3-Are the files listed in step 1 already downloaded in folder temp-encrypted from step 2 4-If the files are not already donloaded > download newest files from S3 bucket into temp-encrypted 5-At end of the day 23:00 take a record of the last files fetched from s3 6-run cleanup script at end of the day to remove everything in temp-encrypted 

I attach a diagram with the intended process and infrastructure design. 我附上一张带有预期流程和基础架构设计的图表。 预期的过程

The solution was like this: 解决方案是这样的:

  1. Change FTPS to SFTP running in Ubuntu 18.04 将FTPS更改为在Ubuntu 18.04中运行的SFTP
  2. change main ports: randomport1 for SSH and randomport2 for SFTP 更改主要端口:SSH的randomport1和SFTP的randomport2
  3. configure SFTP in sshd_config file 在sshd_config文件中配置SFTP
  4. once everything is working create local directory structure 一旦一切正常,创建本地目录结构
  5. by using a bash script 通过使用bash脚本

5.1 List what is in S3 and save in a var 5.1列出S3中的内容并保存在var中

5.2 for each of the files listed in s3 check if there is a new file not present in the mirrored file in the local directory s3-mirror 5.2对于s3中列出的每个文件,检查本地目录s3-mirror中的镜像文件中是否没有新文件

5.3 if there is new file fetch, touch a file with empy contents in s3-mirror directory just same name, move encrypted file to SFTP and remove fetched S3 file from mirrored local directory 5.3如果有新的文件获取,请在s3-mirror目录中触摸一个包含empy内容的文件,其名称相同,将加密的文件移至SFTP并从镜像的本地目录中删除获取的S3文件

5.4 record successful actions in a log. 5.4在日志中记录成功的操作。

So far it works good. 到目前为止,效果很好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用bash脚本将S3中的文件从文件夹递归复制到另一个文件夹? - How to copy files in S3 from folder to another recursively using bash script? 如何在python中更快地从s3读取和处理多个文件? - How to read and process multiple files from s3 faster in python? 一个shell脚本来复制一个文件夹及其所有子文件夹,但请注意它是文件 - a shell script to copy a folder and all it's subfolders, but noit it's files 使用 bash 脚本和“日期”将名为今天日期的文件夹复制到 AWS s3 - Copy folder named today's date to AWS s3 using bash script and `date` 如何为Amazon S3存储桶中的每个文件夹执行命令(如副本)? - How can I execute a command (like copy) for each folder in an Amazon S3 bucket? 在Mac上使用s3cmd在S3中复制文件的简单Shell脚本 - Simple shell script to copy files in S3 using s3cmd on Mac 从 S3 文件夹下载文件并为其创建文件夹的 Shell 脚本 - Shell Script that downloads files from S3 folder and also creates folders for them 将文件从目录中的文件夹复制到新文件夹 - Copy files from a folder in a directory to a new folder 在BASH Ubuntu中按字母顺序复制文件夹中的文件 - Copy files in folders in alphabetical order in BASH Ubuntu BASH:将一个文件夹的所有文件复制到另一个文件夹 - BASH: copy all the files of a folder to other folder
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM