# Moving files to S3 storage

Create a bucket at AWS

1. Select same region as server is hosted in 
    1. Go to [https://eu-north-1.console.aws.amazon.com/s3/buckets](https://eu-north-1.console.aws.amazon.com/s3/buckets)
2. Add bucket
3. Select Directory if files are mainly media (pictures/video)
4. Name the bucket: **s3fs.CUSTOMER**

Add IAM role to server

1. Go to [https://eu-north-1.console.aws.amazon.com/ec2/home](https://eu-north-1.console.aws.amazon.com/ec2/home)
2. Right click server &gt; Security &gt; Modify IAM role
3. Choose **ServerWithNetworkFilesystem**
4. Update IAM role

Install the mountpoint

1. Install software: [https://docs.aws.amazon.com/AmazonS3/latest/userguide/mountpoint-installation.html](https://docs.aws.amazon.com/AmazonS3/latest/userguide/mountpoint-installation.html)
2. Make a folder 
    1. `sudo mkdir /mnt/s3fs`
3. Test the mount 
    1. `sudo mount-s3 --allow-other --dir-mode 0777 --file-mode 0777 <strong>s3fs.CUSTOMER</strong> /mnt/s3fs`
4. Unmount again 
    1. `sudo umount /mnt/s3fs`
5. Modify fstab for automatic mount 
    1. `sudo nano /etc/fstab`
    2. Add a line add the end containing: `s3://<strong>s3fs.CUSTOMER</strong>/ /mnt/s3fs mount-s3 _netdev,nosuid,nodev,nofail,rw,allow-other,dir-mode=0777,file-mode=0777 0 0`
6. Try the fstab mount 
    1. `sudo mount -a`
7. Option for multi instance server: `sudo mkdir /mnt/s3fs/<instancename>`

Change storage location and policy

1. Go to Server &gt; Backend &gt; Modules &gt; Configuration
2. Change filesystemStorageBasePath: /mnt/s3fs 
    - Option for multi instance server: /mnt/s3fs/&lt;instancename&gt;
3. Change filesystemStorageActive: true

Migrate existing files til S3

1. Call server URL 
    - Manual: main?command=dk.tempusserva.codeunit.system.PageConvertBlobsToFiles
    - Full auto: main?command=dk.tempusserva.codeunit.system.PageConvertBlobsToFiles&amp;convert