Support

Akeeba Backup for Joomla!

#39846 Backup just one directory?

Posted in ‘Akeeba Backup for Joomla! 4 & 5’
This is a public ticket

Everybody will be able to see its contents. Do not include usernames, passwords or any other sensitive information.

Environment Information

Joomla! version
4.4.0
PHP version
8.1.22
Akeeba Backup version
9.8.3

Latest post by jjst135 on Friday, 17 November 2023 09:05 CST

jjst135

On one of our sites I want to exclude one folder in the 'images' folder from the regular site backup. This can be easily done by selecting this folder using the 'exclude folder/files' setting. But I would like to have  a second profile to only backup that specific folder. (Zip file, no database). Can I do this and what would be the best way to do it? Or is this not possible?

The reasons I want to split this up: For the one folder I would like a zip, also to a different location and also less frequent.

The default profile for the webiste is truggert by Mysite.guru. Can I trigger the second profile (just the one folder) using a cronjob from our server?

Kind regards,
Jip

jjst135

One way to backup just one folder I tried now:

  • Exclude ALL files and folder (Files and Directories Excluison)
  • Include the specific folder to backup using 'Off-site' Directoy Inclusion'
  • Set the backup to be ZIP.

Now the backup ZIP file only contains this folder (under 'external_files'). There is also an 'installation' folder..This contain some info about the external folders. Probably to be used with restore procedures.

This will probably work for me. But maybe there is a better way?

I noticed there is no database in this backup. This is OK and what I wanted. But I don't believe I have excluded the database form this profile with some setting. So just to clarify for me: Why is the database not included? 

I also think I  can trigger the second profile using a cronjob. I will gve that a try,

nicholas
Akeeba Staff
Manager

You have to think about it the opposite way. You do not want to back up just one folder. You want to have a files-only backup where all files and folders are excluded except a subdirectory of the images folder.

The backup profile needs to have the backup type "Site files only".

Now, we need four things:

  • Exclude all files in the site's root
  • Exclude all top folders except images.
  • Exclude all files directly under images.
  • Exclude all folders under images except folder_to_keep.

The simple and stupid* way to do that is use the Files and Directories Exclusion page. However, if you add any files in the site's root, or any new subdirectories under images you'll have to update the backup profile and we don't want that. So, let's do this properly, with RegEx Files And Directories Exclusion. Finally, 13 years later, someone asks me how to use this feature for the very reason I implemented it in the first place!

We need three regex filters:

  • Exclude file, !#.*/.*#
  • Exclude directory, !#^images(/folder_to_keep(/.*)?)?$#
  • Exclude file, #^images/[^/]*$#

The first one excludes all files in the site's root.

The second one excludes all folders except images itself (we can't exclude, as we need to scan it to find the images/folder_to_keep directory during the backup), the images/folder_to_keep directory, and its subdirectories.

The third one excludes all files directory under the images folder.

So, there you have it! You are now only backing up the contents of images/folder_to_keep.

* No disrespect here. "Simple and stupid" refers to the KISS (Keep It Simple and Stupid) principle in computing, meaning that low-effort solutions are valid solutions as long as they work.

Nicholas K. Dionysopoulos

Lead Developer and Director

🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

jjst135

Hi Nicholas! I am honored to be the first one you can tell about this great feature after all those years. Do you suppose no one has ever used this before? Maybe it was implemented so perfectly many people do use it but never had any questions about is? You never know ;-) 

I am glad the feature is here for this purpose. And it works exactly as you described. Excellent! So thanks very much for creating this funcion 13 years ago! And also for explaining it to me here and now.

Kind regards, Jip

 

 

 

 

 

 

 

Support Information

Working hours: We are open Monday to Friday, 9am to 7pm Cyprus timezone (EET / EEST). Support is provided by the same developers writing the software, all of which live in Europe. You can still file tickets outside of our working hours, but we cannot respond to them until we're back at the office.

Support policy: We would like to kindly inform you that when using our support you have already agreed to the Support Policy which is part of our Terms of Service. Thank you for your understanding and for helping us help you!