# AWS S3 Option for file storage

**URL:** <https://community.open-emr.org/t/aws-s3-option-for-file-storage/18973>\
**Category:** OpenEMR Development\
**Tags:** feature\
**Created:** [August 15, 2022, 12:31pm UTC](https://community.open-emr.org/t/aws-s3-option-for-file-storage/18973 "2022-08-15T12:31:04Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![juggernautsei](https://community.open-emr.org/user_avatar/community.open-emr.org/juggernautsei/32/10764_2.png) [@juggernautsei](https://community.open-emr.org/u/juggernautsei)\
**Post date:** [August 15, 2022, 12:31pm UTC](https://community.open-emr.org/t/aws-s3-option-for-file-storage/18973/1 "2022-08-15T12:31:04Z")

</div>

We are in the process of developing a module that will connect the AWS S3 bucket system as a storage option. The screenshot below is what we have right now.

 ![image](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/3X/f/c/fc9c964a8baf379db0217515a1e286650cc76ca4.png)

---

<div class="post-metadata">

**Author:** ![Nilesh\_Hake](https://community.open-emr.org/user_avatar/community.open-emr.org/nilesh_hake/32/13927_2.png) [@Nilesh\_Hake](https://community.open-emr.org/u/Nilesh_Hake)\
**Post date:** [August 16, 2022, 3:31pm UTC](https://community.open-emr.org/t/aws-s3-option-for-file-storage/18973/2 "2022-08-16T15:31:38Z")

</div>

@juggernautsei,

I had already implemented this feature in OpenEMR for one of my client. Below are flow of process.

1. Upload image to S3 private bucket on AWS.
2. Then display that image into OpenEMR using presinged functionality of AWS server.

---

<div class="post-metadata">

**Author:** ![growlingflea](https://community.open-emr.org/user_avatar/community.open-emr.org/growlingflea/32/15498_2.png) [@growlingflea](https://community.open-emr.org/u/growlingflea)\
**Post date:** [August 16, 2022, 6:19pm UTC](https://community.open-emr.org/t/aws-s3-option-for-file-storage/18973/3 "2022-08-16T18:19:34Z")

</div>

Are you writing this in bash or php? I have a cron job that takes a backup of the database and sites directory and syncs it to AWS S3 storage twice a day.

---

<div class="post-metadata">

**Author:** ![juggernautsei](https://community.open-emr.org/user_avatar/community.open-emr.org/juggernautsei/32/10764_2.png) [@juggernautsei](https://community.open-emr.org/u/juggernautsei)\
**Post date:** [August 16, 2022, 6:40pm UTC](https://community.open-emr.org/t/aws-s3-option-for-file-storage/18973/4 "2022-08-16T18:40:20Z")

</div>

I am building a module. Yes, I am writing it in PHP.  
@Nilesh_Hake I know that doing private work does not lend itself to sharing. My question is did you tie it into the patient documents so that instead of saving the files on the local instance. The files are saved in the S3 bucket via the normal document work flow.  
Our goal for this module is to add to the ways to save files.

 ![image](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/3X/3/1/31a0b1692aecbbbdbcded9f402cbbb77352d7b90.png)

During the build process, I have the code write a test file to the S3. That is as far as I have gotten.

---

<div class="post-metadata">

**Author:** ![growlingflea](https://community.open-emr.org/user_avatar/community.open-emr.org/growlingflea/32/15498_2.png) [@growlingflea](https://community.open-emr.org/u/growlingflea)\
**Post date:** [August 16, 2022, 6:54pm UTC](https://community.open-emr.org/t/aws-s3-option-for-file-storage/18973/5 "2022-08-16T18:54:22Z")

</div>

Sounds good. I’m wondering, are you doing more than just syncing the data to the S3 bucket? The solution I used is about six lines of code, three lines in the crontab file and the file that takes a mysql dump. You will need to have the aws library installed on the server. The cronjob runs the backupsql.sh file which is just a mysql dump which saves the database to the /opt/backups folder. Then I sync the sites directory and the backups folder to S3 server.

45 12,21 \* \* \* sh /opt/backups/backupsql.sh  
34 23 \* \* \* aws s3 sync /var/www/openemr/sites/ s3://sqldump-bucket/sites  
30 12,22 \* \* \* aws s3 sync /opt/backups/ s3://sqldump-bucket/mysqldumps

The backup script is below:

```nohighlight
date > backup-date.log
now=$(date +"%Y_%m_%d_%H_%M_%S")
mysqldump --user=openemr --password=openemrPassword openemr > ${now}_daily-all-dbs.sql
gzip ${now}_daily-all-dbs.sql
rm ${now}_daily-all-dbs.sql
date >> backup-date.log

```

---

<div class="post-metadata">

**Author:** ![juggernautsei](https://community.open-emr.org/user_avatar/community.open-emr.org/juggernautsei/32/10764_2.png) [@juggernautsei](https://community.open-emr.org/u/juggernautsei)\
**Post date:** [August 16, 2022, 7:11pm UTC](https://community.open-emr.org/t/aws-s3-option-for-file-storage/18973/6 "2022-08-16T19:11:11Z")

</div>

Yes, we are going to be writing and reading the document files from the S3 bucket. It is not just for backup.

---

<div class="post-metadata">

**Author:** ![growlingflea](https://community.open-emr.org/user_avatar/community.open-emr.org/growlingflea/32/15498_2.png) [@growlingflea](https://community.open-emr.org/u/growlingflea)\
**Post date:** [August 16, 2022, 7:14pm UTC](https://community.open-emr.org/t/aws-s3-option-for-file-storage/18973/7 "2022-08-16T19:14:19Z")

</div>

The way that I understand how S3 works is that is doesn’t cost anything (or very little) to write to the drive but its very expensive to read or pull data out. If you are going to be writing and reading data, you might want to choose a different service.

---

<div class="post-metadata">

**Author:** ![juggernautsei](https://community.open-emr.org/user_avatar/community.open-emr.org/juggernautsei/32/10764_2.png) [@juggernautsei](https://community.open-emr.org/u/juggernautsei)\
**Post date:** [August 16, 2022, 7:39pm UTC](https://community.open-emr.org/t/aws-s3-option-for-file-storage/18973/8 "2022-08-16T19:39:07Z")

</div>

@jesdynf could you chime in on the cost of the S3 bucket? I don’t know but since you are well versed on AWS. Maybe you know the cost aspect of using S3 and why you want to use S3 instead of the local file system.

According to AWS calculator, this is the cost

- Inbound:

- Internet: 5 GB x 0 USD per GB = 0.00 USD

- Outbound:

- Internet: 5 GB x 0.09 USD per GB = 0.45 USD

- **Data Transfer cost (monthly): 0.45 USD**

> **[AWS Pricing Calculator](https://calculator.aws/#/addService/S3)**
>
> AWS Pricing Calculator lets you explore AWS services, and create an estimate for the cost of your use cases on AWS.

---

<div class="post-metadata">

**Author:** ![jesdynf](https://community.open-emr.org/user_avatar/community.open-emr.org/jesdynf/32/15698_2.png) [@jesdynf](https://community.open-emr.org/u/jesdynf)\
**Post date:** [August 16, 2022, 8:16pm UTC](https://community.open-emr.org/t/aws-s3-option-for-file-storage/18973/9 "2022-08-16T20:16:41Z")

</div>

That’s flat wrong, yes. Perhaps he’s referring to Glacier?

[Amazon S3 Simple Storage Service Pricing - Amazon Web Services](https://aws.amazon.com/s3/pricing/) covers the ground. S3 is designed to affordably transfer terabytes of static documents. You pay for the storage (and that’s honestly the largest cost over time, 2.3 cents per GB/mo), you pay for the data transfer (and you’ve got the math correct there), and you pay tiny fractions of pennies for the document transfer requests. ($0.005 per thousand puts, $0.0004 per thousand gets).

And think about it – how often do these _patient documents_ get actually uploaded or downloaded? These aren’t framework .js files or something looked at on pageload, there’s only so many times in the lifespan of any given document it’ll be looked at.

---

<div class="post-metadata">

**Author:** ![juggernautsei](https://community.open-emr.org/user_avatar/community.open-emr.org/juggernautsei/32/10764_2.png) [@juggernautsei](https://community.open-emr.org/u/juggernautsei)\
**Post date:** [August 17, 2022, 11:27am UTC](https://community.open-emr.org/t/aws-s3-option-for-file-storage/18973/10 "2022-08-17T11:27:02Z")

</div>

So, to put real numbers behind what @jesdynf said.  
We have **78GB** of data right now that took over **10yrs** to accumulate. So you know some of those documents from the first few patients will never be looked at again. The storage of that 78GB of data will cost **$1.79/mo** sitting in an **S3 bucket**.  
The redundancy that is offered by the S3 bucket is worth the monthly cost. For pennies, the files are written across three different data centers. Now, that is data availability and security wrapped into one. No more wondering if the cron job failed.

---

<div class="post-metadata">

**Author:** ![Nilesh\_Hake](https://community.open-emr.org/user_avatar/community.open-emr.org/nilesh_hake/32/13927_2.png) [@Nilesh\_Hake](https://community.open-emr.org/u/Nilesh_Hake)\
**Post date:** [August 17, 2022, 11:44am UTC](https://community.open-emr.org/t/aws-s3-option-for-file-storage/18973/11 "2022-08-17T11:44:58Z")

</div>

Write now I have implemented this functionality for the upload doctor signature into S3 private bucket and then display that image into openemr using presign functionality of OpenEMR. Later we will going to work on the patient document nas well.

---

<div class="post-metadata">

**Author:** ![TranMedical](https://community.open-emr.org/user_avatar/community.open-emr.org/tranmedical/32/17435_2.png) [@TranMedical](https://community.open-emr.org/u/TranMedical)\
**Post date:** [August 29, 2022, 9:55pm UTC](https://community.open-emr.org/t/aws-s3-option-for-file-storage/18973/12 "2022-08-29T21:55:18Z")

</div>

I was also working on this but for google cloud. Currently it works though I’m not sure it is optimal for speed.

I used the docker image setup. What I did:

1. I fuse mounted my bucket.
2. I had mounted my sites dir to a docker persistent volume, so I let that set up first.
3. Then I copied over the documents dir within the sites dir into my fuse mounted dir.
4. Then I symlinked the documents path to the fuse mounted dir

Not sure if its helpful but it seems to work.

---

<div class="post-metadata">

**Author:** ![jesdynf](https://community.open-emr.org/user_avatar/community.open-emr.org/jesdynf/32/15698_2.png) [@jesdynf](https://community.open-emr.org/u/jesdynf)\
**Post date:** [August 30, 2022, 2:18pm UTC](https://community.open-emr.org/t/aws-s3-option-for-file-storage/18973/13 "2022-08-30T14:18:31Z")

</div>

A single instance routing to S3 might work okayish like that. In this configuration S3 is just a hot backup, no different from an rsync. You’re storing, but not serving, from S3. You wouldn’t be able to use a cluster of workers to serve from it – you could try, but that’s when the whole thing would fall to pieces.

---

<div class="post-metadata">

**Author:** ![Marco\_Meza](https://community.open-emr.org/user_avatar/community.open-emr.org/marco_meza/32/18988_2.png) [@Marco\_Meza](https://community.open-emr.org/u/Marco_Meza)\
**Post date:** [April 11, 2024, 8:24pm UTC](https://community.open-emr.org/t/aws-s3-option-for-file-storage/18973/14 "2024-04-11T20:24:52Z")

</div>

Hi,  
I wonder if you have completed this feature?  
I wish to use S3 as repository for dicom results.

Thanks!

---

<div class="post-metadata">

**Author:** ![juggernautsei](https://community.open-emr.org/user_avatar/community.open-emr.org/juggernautsei/32/10764_2.png) [@juggernautsei](https://community.open-emr.org/u/juggernautsei)\
**Post date:** [April 11, 2024, 9:30pm UTC](https://community.open-emr.org/t/aws-s3-option-for-file-storage/18973/15 "2024-04-11T21:30:30Z")

</div>

Yes, it works. I will PM you about the module.

---

<div class="post-metadata">

**Author:** ![juggernautsei](https://community.open-emr.org/user_avatar/community.open-emr.org/juggernautsei/32/10764_2.png) [@juggernautsei](https://community.open-emr.org/u/juggernautsei)\
**Post date:** [April 11, 2024, 10:26pm UTC](https://community.open-emr.org/t/aws-s3-option-for-file-storage/18973/16 "2024-04-11T22:26:04Z")

</div>

> [@jesdynf](#):
>
> A single instance routing to S3 might work okayish like that. In this configuration S3 is just a hot backup, no different from an rsync. You’re storing, but not serving, from S3. You wouldn’t be able to use a cluster of workers to serve from it – you could try, but that’s when the whole thing would fall to pieces.

I took @jesdynf advice and the documents are served from the S3 bucket. It can complete replace the local storage.

---

<div class="post-metadata">

**Author:** ![casper](https://community.open-emr.org/user_avatar/community.open-emr.org/casper/32/21481_2.png) [@casper](https://community.open-emr.org/u/casper)\
**Post date:** [January 23, 2025, 10:43am UTC](https://community.open-emr.org/t/aws-s3-option-for-file-storage/18973/17 "2025-01-23T10:43:35Z")

</div>

This is an interesting features hope this can be added as official module in open emr 🙂

---

<div class="post-metadata">

**Author:** ![mattsuhmd](https://community.open-emr.org/letter_avatar_proxy/v4/letter/m/34f0e0/32.png) [@mattsuhmd](https://community.open-emr.org/u/mattsuhmd)\
**Post date:** [August 1, 2025, 7:19pm UTC](https://community.open-emr.org/t/aws-s3-option-for-file-storage/18973/18 "2025-08-01T19:19:41Z")

</div>

Hello, Sherwin

I am a new user and just recently deployed Cloud Express 7.0.3 on AWS.  
Can I use the S3 storage module?

Thanks,

Matthew

---

<div class="post-metadata">

**Author:** ![juggernautsei](https://community.open-emr.org/user_avatar/community.open-emr.org/juggernautsei/32/10764_2.png) [@juggernautsei](https://community.open-emr.org/u/juggernautsei)\
**Post date:** [August 1, 2025, 7:45pm UTC](https://community.open-emr.org/t/aws-s3-option-for-file-storage/18973/19 "2025-08-01T19:45:48Z")

</div>

Send me an email [sherwingaddis@gmail.com](mailto:sherwingaddis@gmail.com). I will send you the module.

---

<div class="post-metadata">

**Author:** ![usamak](https://community.open-emr.org/letter_avatar_proxy/v4/letter/u/b5e925/32.png) [@usamak](https://community.open-emr.org/u/usamak)\
**Post date:** [May 14, 2026, 6:00pm UTC](https://community.open-emr.org/t/aws-s3-option-for-file-storage/18973/20 "2026-05-14T18:00:16Z")

</div>

Hello, Sherwin

Is the module available now on openemr code base?

Another one, can we use another alternative like MinIO?

Thanks

[Next page](https://community.open-emr.org/t/aws-s3-option-for-file-storage/18973.md?page=2)
