Schedule your backup with WP Cron – https://codex.wordpress.org/Function_Reference/wp_schedule_event
In the cron event, run your query for posts or CPTs and be sure to add 'numberposts' => -1,
to return all.
When you loop through your posts from the resulting query, push the values to an array $data[]=$some_string_data_for_prop;
- https://www.advancedcustomfields.com/resources/get_field/
- https://developer.wordpress.org/reference/functions/get_post_meta/
- https://codex.wordpress.org/Class_Reference/WP_Post
And when you’re ready to write the data, convert the array values to a single string; $output = implode("\n", $data);
Then write the data to a file file_put_contents($filepath, $output);