Difference between revisions of "Migrating Between Storage Locations"

From WHMCS Documentation

(Created page with "You may want to migrate files from one local storage location to another, or from an existing storage location to an AWS S3 bucket or a compatible service. ==Migrating Local...")
 
(Migrating to AWS S3)
 
(One intermediate revision by the same user not shown)
Line 12: Line 12:
  
 
# Create your S3 configuration. For steps to set one up, see [https://help.whmcs.com/m/system/c/281650 our guides and tutorials].
 
# Create your S3 configuration. For steps to set one up, see [https://help.whmcs.com/m/system/c/281650 our guides and tutorials].
# In the WHMCS Admin Area, navigate to '''Configuration (<i class="fa fa-wrench" aria-hidden="true"></i>) > System Settings > Storage Settings''' and click the '''Configuration''' tab.
+
# In the WHMCS Admin Area, go to '''Configuration (<i class="fa fa-wrench" aria-hidden="true"></i>) > System Settings > [[Storage Settings]]''' or, prior to WHMCS 8.0, '''Setup > Storage Settings'''.
# Under '''Add New Configuration''', select '''S3'''.
+
# Choose the '''Configuration''' tab.
# Click the + icon.
+
# Under '''Add New Configuration''', choose '''S3'''.
 +
# Click the '''+''' icon.
 
# Enter your AWS S3 connection details.  
 
# Enter your AWS S3 connection details.  
#* You must specify the S3 region by its code name (for example, <tt>us-east-1</tt> for ''US East (N. Virginia)''). To find the region code name for a bucket's region, [https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Concepts.RegionsAndAvailabilityZones.html click here].  
+
#* You must specify the S3 region by its [https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Concepts.RegionsAndAvailabilityZones.html code name] (for example, <tt>us-east-1</tt> for ''US East (N. Virginia)'').
#*The system doesn't require the '''Endpoint URL''' value if you're using the Amazon AWS S3 service. This is only required if you are using a non-Amazon, S3-compatible storage provider.
+
#*The system doesn't require the '''Endpoint URL''' value if you're using the Amazon AWS S3 service. This is only required if you are using a non-Amazon S3-compatible storage provider.
#*The S3 access credentials must have read and write access to the specified S3 bucket. See below for an example of a suitable policy for the S3 user.
+
#*The S3 access credentials must have read and write access to the specified S3 bucket.
#Click '''Save'''. If the system can't access the bucket, an error message will appear. If this happens, check the entered details and try again.
+
#** This must include the following permissions:
#Click on the '''Settings''' tab.  
+
#*** '''ListBucket'''
#Select the new storage location for the file type that you wish to migrate to the new location. The system can migrate most file types automatically.  
+
#*** '''GetObject'''
# Click '''Migrate'''.
+
#*** '''PutObject'''
#*Smaller migrations will require less than a minute.
+
#*** '''ReplicateObject'''
#*If the system can't complete the migration immediately, it will schedule it to run in the background. Until it finishes, the system will continue to use the former location.  
+
#*** '''DeleteObject'''
#** When the migration is finished, the setting will automatically switch to the new selection and begin using the new location.  
+
#** See below for an example of a suitable policy for the S3 user.
#** You may choose to cancel an ongoing migration. If you do, the system will continue to use the present location. Files that the system already migrated to the new location will remain.
+
# Click '''Save'''. If the system can't access the bucket, an error message will appear. If this happens, check the entered details and try again.
 +
# Choose the '''Settings''' tab.  
 +
# Select the new storage location for the file type that you wish to migrate to the new location.
 +
# Click '''Migrate''' when the system prompts you to migrate the files automatically.
 +
#*For smaller scale deployments, migration will take less than a minute, and your files will then be stored at the new location.
 +
#*If the migration cannot be completed immediately, it will be scheduled to run in the background. Until it is completed, the former location will continue to be used.
 +
# After the automatic migration finishes, validate whether the migration was successful.
 +
# Delete the files in the prior location. The system will not automatically delete these files.
  
The system won't automatically remove files from the former location. Do this manually after you verify that the migration was successful.
+
When the migration is finished, the setting will automatically switch to the new selection and begin using the new location. You may choose to cancel an ongoing migration. If you do, the system will continue to use the present location. Files that the system already migrated to the new location will remain.
  
 
===Manual Migration===
 
===Manual Migration===
Line 68: Line 76:
  
 
====For Manual Migrations====
 
====For Manual Migrations====
 +
 
For manual migrations, the system stores files in AWS S3 with a prefix corresponding to the file asset type. For example, it will store file1.png, a client file, as /client_files/file1.png. Use the following sub-folder names per file type:  
 
For manual migrations, the system stores files in AWS S3 with a prefix corresponding to the file asset type. For example, it will store file1.png, a client file, as /client_files/file1.png. Use the following sub-folder names per file type:  
  
Line 81: Line 90:
 
===Migrating Between Two AWS S3 locations===
 
===Migrating Between Two AWS S3 locations===
  
In addition to Amazon AWS S3, WHMCS supports AWS S3 compatible services like Ceph. However, WHMCS only supports automatic migration between two S3 locations if both locations use the same storage provider.  
+
In addition to Amazon AWS S3, WHMCS supports AWS S3 compatible services like Ceph. However, WHMCS only supports automatic migration between two S3 locations if both locations use the same storage provider.
  
 
==Migrating From S3 To Local Storage==
 
==Migrating From S3 To Local Storage==
Line 89: Line 98:
 
==General Considerations==
 
==General Considerations==
  
Note that the system can't automatically migrate '''Email Attachments''' (as opposed to email template attachments). You upload these files when creating a custom email message, and they are of a transient nature. To avoid any inconsistencies when switching storage settings for email attachments, it should be sufficient to ensure that no administrator users are in process of composing an email message with attachments. Note that email template attachments are a separate asset type that you can migrate automatically.
+
The system can't automatically migrate '''Email Attachments''' (as opposed to email template attachments). You upload these files when creating a custom email message, and they are of a transient nature. To avoid any inconsistencies when switching storage settings for email attachments, it should be sufficient to ensure that no administrator users are in process of composing an email message with attachments. Note that email template attachments are a separate asset type that you can migrate automatically.
  
 
==Troubleshooting a File Not Found Error==
 
==Troubleshooting a File Not Found Error==

Latest revision as of 14:20, 6 February 2023

You may want to migrate files from one local storage location to another, or from an existing storage location to an AWS S3 bucket or a compatible service.

Migrating Local Storage

To migrate files from an existing local storage location to another local directory:

  1. Go to Configuration () > System Settings > Storage Settings or, prior to WHMCS 8.0, Setup > Storage Settings.
  2. Choose the Configuration tab.
  3. Under Add New Configuration, choose Local Storage and click Add.
  4. Enter path to the new storage location and click Save. The directory must exist and be writable.
  5. Choose the Settings tab.
  6. Select the new storage location for the file type that you wish to migrate to the new location.
  7. Click Migrate when the system prompts you to migrate the files automatically.
    • For smaller scale deployments, migration will take less than a minute, and your files will then be stored at the new location.
    • If the migration cannot be completed immediately, it will be scheduled to run in the background. Until it is completed, the former location will continue to be used. Once all files are migrated to the new location, the setting will automatically switch to the new selection and begin using the new location.
    • Instead of using automated migration, you may opt to migrate your files manually and switch the relevant file type's storage setting immediately.
      • This will skip automatic migration and assumes your responsibility for moving the files to the new location.
      • Some file types may be stored by WHMCS in the same folder (for example, client files, email and ticket attachments as well as project management files will be stored in "attachments" folder). If you decide to move all the files away from that folder, all relevant file types must be switched to the new location.
  8. After the automatic migration finishes, validate whether the migration was successful.
  9. Delete the files in the prior location. The system will not automatically delete these files.

You may choose to cancel an ongoing migration. The present location will then continue to be used. Files migrated to the new location until this point will not be deleted.

If you make a change by mistake, click Revert Changes to cancel any changes.

Migrating to AWS S3

To migrate to AWS:

  1. Create your S3 configuration. For steps to set one up, see our guides and tutorials.
  2. In the WHMCS Admin Area, go to Configuration () > System Settings > Storage Settings or, prior to WHMCS 8.0, Setup > Storage Settings.
  3. Choose the Configuration tab.
  4. Under Add New Configuration, choose S3.
  5. Click the + icon.
  6. Enter your AWS S3 connection details.
    • You must specify the S3 region by its code name (for example, us-east-1 for US East (N. Virginia)).
    • The system doesn't require the Endpoint URL value if you're using the Amazon AWS S3 service. This is only required if you are using a non-Amazon S3-compatible storage provider.
    • The S3 access credentials must have read and write access to the specified S3 bucket.
      • This must include the following permissions:
        • ListBucket
        • GetObject
        • PutObject
        • ReplicateObject
        • DeleteObject
      • See below for an example of a suitable policy for the S3 user.
  7. Click Save. If the system can't access the bucket, an error message will appear. If this happens, check the entered details and try again.
  8. Choose the Settings tab.
  9. Select the new storage location for the file type that you wish to migrate to the new location.
  10. Click Migrate when the system prompts you to migrate the files automatically.
    • For smaller scale deployments, migration will take less than a minute, and your files will then be stored at the new location.
    • If the migration cannot be completed immediately, it will be scheduled to run in the background. Until it is completed, the former location will continue to be used.
  11. After the automatic migration finishes, validate whether the migration was successful.
  12. Delete the files in the prior location. The system will not automatically delete these files.

When the migration is finished, the setting will automatically switch to the new selection and begin using the new location. You may choose to cancel an ongoing migration. If you do, the system will continue to use the present location. Files that the system already migrated to the new location will remain.

Manual Migration

Instead of using automated migration, you may opt to migrate your files manually and switch the relevant file types storage setting at once. This will skip automatic migration and you will be responsible for moving the files to the new location.

If you use this method, note that WHMCS may store certain file types in the same folder (for example, the system will store client files, email and ticket attachments, and project management files in the attachments folder). If you decide to move all the files away from that local folder, you must switch all relevant file types to the new location.

If you made a change by mistake, click Revert Changes to cancel any changes.

Example Security Policy

Consider using the IAM Policy Generator tool in the AWS control panel or the public policy generator tool.

For advanced users, an example AWS S3 policy to assign to the S3 user for use with WHMCS storage settings is below:

   {
       "Version": "2012-10-17",
       "Statement": [
           {
               "Sid": "Stmt1111222223333",
               "Effect": "Allow",
               "Action": [
                   "s3:ListBucket",
                   "s3:GetObject",
                   "s3:GetObjectAcl",
                   "s3:PutObject",
                   "s3:PutObjectAcl",
                   "s3:ReplicateObject",
                   "s3:DeleteObject"
               ],
               "Resource": [
                   "arn:aws:s3:::<BUCKET_NAME>",
                   "arn:aws:s3:::<BUCKET_NAME>/*"
               ]
           }
       ]
   }

For Manual Migrations

For manual migrations, the system stores files in AWS S3 with a prefix corresponding to the file asset type. For example, it will store file1.png, a client file, as /client_files/file1.png. Use the following sub-folder names per file type:

  • Client Files — client_files
  • Downloads — downloads
  • Email Attachments — email_attachments
  • Email Template Attachments — template_attachments
  • Project Management Files — pm_files
  • Ticket Attachments — ticket_attachments

When using automatic migration, you do not have to worry about these prefixes; the system manages them automatically.

Migrating Between Two AWS S3 locations

In addition to Amazon AWS S3, WHMCS supports AWS S3 compatible services like Ceph. However, WHMCS only supports automatic migration between two S3 locations if both locations use the same storage provider.

Migrating From S3 To Local Storage

You can perform this migration the same way as the other migration paths, with the same considerations and expectations equally applicable.

General Considerations

The system can't automatically migrate Email Attachments (as opposed to email template attachments). You upload these files when creating a custom email message, and they are of a transient nature. To avoid any inconsistencies when switching storage settings for email attachments, it should be sufficient to ensure that no administrator users are in process of composing an email message with attachments. Note that email template attachments are a separate asset type that you can migrate automatically.

Troubleshooting a File Not Found Error

If you experience a File not found error, this may mean that a file is not present or is not accessible at the expected location.

For steps to troubleshoot this, see Troubleshooting a File Not Found Error.