Almost everybody knows (and has used) the WordPress Duplicator plugin. It allows you to quickly backup your site to set it up on a new server or just for your own backups.
The things that I don't like is that it requires a fresh database when importing a site and will delete any other db tables. Of course it warns you about that and doesn't do it in a surprising way.
When exporting a site and if you share the same database with other apps or another WordPress install you have to manually choose which tables to exclude from the backup. I am sure the author Cory Lamle has had good reasons to have those in place.
I know that there's a Duplicator Pro version. Maybe it doesn't have those limitations. I haven't used it just yet.
Depending on your reasons to package the site you will need to exclude some files and not others.
Scenario 1: Troubleshooting a theme or a plugin: partial WordPress site backup
You want to quickly troubleshoot a plugin or a theme. In this case you don't need everything from the uploads folder. That way the package will be smaller and the packaging process will finish quicker.
Hmm, on second thought maybe you want it to take longer ;) Ok. Let's get back to writing.
File Directories to exclude:
/var/www/vhosts/somesite.com/htdocs/wp-content/uploads;
/var/www/vhosts/somesite.com/htdocs/wp-content/*backup*;
/var/www/vhosts/somesite.com/htdocs/wp-content/*cache*;
File Extensions to exclude:
zip;tar;log;txt;gz;bak;mp3;mp4;pdf;doc;docx;xls;xlsx
We're excluding all of those files types/extensions because they won't help in any way the troubleshooting process.
Scenario 2: (Almost) full WordPress site backup
File Directories to exclude:
/var/www/vhosts/somesite.com/htdocs/wp-content/*backup*;
/var/www/vhosts/somesite.com/htdocs/wp-content/*cache*;
File Extensions to exclude:
zip;tar;log;txt;gz;bak
We're surrounding backup with asterisks so 'backup' keyword can appear anywhere in the folder name. We want those excluded from the final archive file because they most likely be full site copies created by another backup plugin. The same applies to cache folders.
Note: I have used [/var/www/vhosts/somesite.com] as an example file path to the document root of the site. Your site's root dir will most likely be different. Fortunately, Duplicator has 2-3 useful links that you can click on to find out what's the exact root path. If you're not using the correct path the exclusions won't work.
What files or folders do you exclude from your backup/clone process?