# Moving Files from an existing disk store to s3

**URL:** https://forum.mattermost.com/t/moving-files-from-an-existing-disk-store-to-s3/3306
**Category:** Troubleshooting
**Created:** [May 23, 2017, 2:59am UTC](https://forum.mattermost.com/t/moving-files-from-an-existing-disk-store-to-s3/3306 "2017-05-23T02:59:24Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![xingliu](https://avatars.discourse-cdn.com/v4/letter/x/53a042/32.png) [@xingliu](https://forum.mattermost.com/u/xingliu)
#### Post date: [May 23, 2017, 2:59am UTC](https://forum.mattermost.com/t/moving-files-from-an-existing-disk-store-to-s3/3306/1 "2017-05-23T02:59:24Z")

</div>

Hello,

I have a mattermost team instance that is configured to use the default file system location to store attachments. The server has been in use, and there are files in the data directory? How would I move the existing files to S3?

---

<div class="post-metadata">

### Author: ![yoshtec](https://avatars.discourse-cdn.com/v4/letter/y/839c29/32.png) [@yoshtec](https://forum.mattermost.com/u/yoshtec)
#### Post date: [May 23, 2017, 9:28pm UTC](https://forum.mattermost.com/t/moving-files-from-an-existing-disk-store-to-s3/3306/2 "2017-05-23T21:28:18Z")

</div>

Would also be interested in a solution.

---

<div class="post-metadata">

### Author: ![hmhealey](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/hmhealey/32/1915_2.png) [@hmhealey](https://forum.mattermost.com/u/hmhealey)
#### Post date: [May 30, 2017, 2:27pm UTC](https://forum.mattermost.com/t/moving-files-from-an-existing-disk-store-to-s3/3306/3 "2017-05-30T14:27:44Z")

</div>

Hi @xingliu and @yoshtec,

As long as you keep the folder structure of the data folder the same as the structure of the S3 bucket (for example, `data/teams/12345` becomes `teams/12345` in the S3 bucket), you should be able to just switch your Mattermost instance to use S3 for file storage without problems. If you use the [AWS Command Line Interface](http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-welcome.html), there’s an [`aws s3 sync` command](http://docs.aws.amazon.com/cli/latest/reference/s3/sync.html) that should be able to copy everything over for you

---

<div class="post-metadata">

### Author: ![kylerlaird](https://avatars.discourse-cdn.com/v4/letter/k/b5a626/32.png) [@kylerlaird](https://forum.mattermost.com/u/kylerlaird)
#### Post date: [February 10, 2020, 2:26pm UTC](https://forum.mattermost.com/t/moving-files-from-an-existing-disk-store-to-s3/3306/4 "2020-02-10T14:26:08Z")

</div>

It really is this simple! I quickly set up Mattermost with local storage to escape from Slack. It’s been wonderful! I wanted to start uploading more files but I was concerned about space. S3 is the obvious solution. I migrated painlessly.

Here are some notes from my migration…  
AWS IAM policy:  
[from [AWS S3: The right policy to set - Antoine Aflalo](https://www.aaflalo.me/2017/07/aws-s3-right-policy-set/)]

> ```
> {
> "Version": "2012-10-17",
> "Statement": [
> {
> "Effect": "Allow",
> "Action": [
> "s3:ListBucket",
> "s3:GetBucketLocation"
> ],
> "Resource": [
> "arn:aws:s3:::BUCKET_NAME"
> ]
> },
> {
> "Effect": "Allow",
> "Action": [
> "s3:PutObject",
> "s3:GetObject",
> "s3:DeleteObject"
> ],
> "Resource": [
> "arn:aws:s3:::BUCKET_NAME/*"
> ]
> }
> ]
> }
> 
> ```

> $ aws s3 sync /opt/mattermost/data/ s3://BUCKET\_NAME

System Console → Environment → File Storage  
After configuring for S3, you have to save the configuration _before_ testing it.

Changes seemed to take effect immediately after testing. (I uploaded a photo and it saved in S3.) I did restart the server to ensure it was still working properly, though,

> systemctl restart mattermost

Thanks, All!

---

<div class="post-metadata">

### Author: ![raghu777](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/raghu777/32/6273_2.png) [@raghu777](https://forum.mattermost.com/u/raghu777)
#### Post date: [January 22, 2023, 8:11am UTC](https://forum.mattermost.com/t/moving-files-from-an-existing-disk-store-to-s3/3306/5 "2023-01-22T08:11:43Z")

</div>

Thank you for the steps.  
Notes:

1. If you are not doing the above steps as a mattermost user I suggest executing following command,  
`sudo usermod -G mattermost <current-user>`  
`sudo chmod -R 750 /var/opt/mattermost/data`
2. And you will have to restart services to take effect the changes.

---

<div class="post-metadata">

### Author: ![Adrian](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/adrian/32/7104_2.png) [@Adrian](https://forum.mattermost.com/u/Adrian)
#### Post date: [August 5, 2023, 8:38am UTC](https://forum.mattermost.com/t/moving-files-from-an-existing-disk-store-to-s3/3306/6 "2023-08-05T08:38:07Z")

</div>

To move the existing files from the default file system location to Amazon S3 in your Mattermost team instance, you have a few options:

1- Using an S3 migration tool : There are third-party tools specifically designed for migrating files from a local file system to Amazon S3. These tools often provide a user-friendly interface and automate the migration process. One such tool is “s3-syncer,” which you can find on GitHub. also you can try Gs Richcopy 360 or ShareGate .

2- Using the AWS Command Line Interface (CLI): The AWS CLI provides a comprehensive set of commands to interact with various AWS services, including S3. You can use the `aws s3 sync` command to synchronize the files from your local directory to an S3 bucket.

3- Manual upload using S3 tools: If you prefer a more manual approach, you can use S3 tools like `s3cmd` or the AWS Management Console to upload the files manually. With `s3cmd` , you can use the `put` command to upload files to your S3 bucket.
