Data backup in salesforce

I need to develop an Apex script to backup all the database data every day. Is there an optimal way to do that? What could be needed to be done if pictures or pdf files are saved in the database?

Thanks in Advance

1 Answer 1


Daily full backups would be impractical/impossible for anything other than the smallest of organizations, mostly because there's a asynchronous call/day limit, plus all the other governor limits. Your best option would probably be to to use the Data Replication API to perform incremental backups from an external system. The replication API also makes sure that you don't miss any deletions, if that's important. Keep in mind that you can also perform a Weekly or Monthly export in the higher editions of salesforce. Those backups can be full backups, including all files and documents hosted in salesforce.

  • Well, your solution is very interesting and I will try to follow it. On the other hand, we are a very small organization but we consider our data very important. Then, as curiosity, can you please tell me the way to do daily backups from Apex? Thanks a lot!! On the other hand, how the CVS files could have data like pdf, pictures or stuff like this?
    – Jose
    Commented Jun 6, 2016 at 19:30
  • 1
    @JoseCabreraZuniga There's a lot of variables in play: it depends on how many fields per object, how many records per object, where you're going to send these files to, and so on. It's not trivial to build this in Apex, because there are a lot of limits in your way. Using external computing makes more sense. As far as storing binary data in CSV, you just have to encode it using EncodingUtil.base64Encode. It'd take me far too long to even write up a demo-- it's not an easy task given the limits of the platform.
    – sfdcfox
    Commented Jun 6, 2016 at 19:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .