ERPNext Amazon S3 Backup settings

We are trying to configure amazon_S3_backup settings to take periodic backup of ERPNext instance. We have followed the below steps to install amazon_s3_backup…

Install boto and filechunkio packages
a) source ./frappe-bench/env/bin/activate
b) pip install boto
c) pip install filechunkio

bench get-app s3_backup https://github.com/ccfiel/s3_backup.git

bench --site install-app s3_backup

After installation new link available under Setup > Integrations > Amazon S3 Backup
But while trying the save the configuration settings its giving the below error…can someone please advise or suggest a solution to this issue…really appreciate an early response.

Traceback (most recent call last):
File “/home/frappe/frappe-bench/apps/frappe/frappe/desk/form/save.py”, line 22, in savedocs
doc.save()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 259, in save
return self.save(*args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 293, in save
self.run_before_save_methods()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 861, in run_before_save_methods
self.run_method(“validate”)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 757, in run_method
out = Document.hook(fn)(self, *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 1026, in composer
return composed(self, method, *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 1009, in runner
add_to_return_value(self, fn(self, *args, **kwargs))
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 751, in
fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
File “/home/frappe/frappe-bench/apps/s3_backup/s3_backup/amazon_s3_backup/doctype/amazon_s3_settings/amazon_s3_settings.py”, line 29, in validate
frappe.throw(("Unable to create bucket {0}. Change it to a more unique ").format(bucket_lower))
NameError: global name ‘_’ is not defined

try with this edit
bench --site erpnext install-app s3_backup

Thanks for your reply…
it worked after I change the AWS User permission policy…
earlier I was using a custom policy…

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "s3:ListAllMyBuckets",
                "s3:PutObject",
                "s3:GetObject"
            ],
            "Resource": [
                "arn:aws:s3:::*"
            ]
        }
    ]
}

changed it to amazon standard permission of AmazonS3FullAccess

its having following permission…

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": "s3:*",
            "Resource": "*"
        }
    ]
}
2 Likes

thanks… will keep it for my team as well.

  1. do you mean the “Bucket Policy” in the “Permissions” tab inside of the bucket?
  2. it’s the 2nd code example in your post which is the one that works for you?

I am getting a …

Missing required field Principal

… error when pasting this 1:1 into the “Bucket Policy” field

while trying to figure out the s3 bucket policy, all of a sudden (without having changed or added to the policy yet) I see a backup showing in my bucket. So it is solved for me without me knowing why. I’m curious if this continous to work

P.S. I am on v11 where s3 backup is built in