Backup a script

Is it possible to include into backup a custom script created manually , to be restored in same position ?
Should I put into a specific directory ?

Yes, you can include the custom script in the backup, and it will be restored to the same place.
Note: The restore job will be executed using the asterisk user, so the path or directory should be accessible from asterisk user otherwise, it will fail due to a permission error.

Will it also be restored if located into a user created directory (i.e. /home/mydirectory/) ??
Or should it be present inside a system directory like /etc/asterisk or /var/lib/asterisk ?

If you add /home/myfolder it gets restored to /home/myfolder. It just needs to be owned by asterisk.

I’m talking about Freepbx module backup/restore.
When one restores a backup, it is done on a working centOS machine
Restoring /home/myfolder assumes the original backup process takes care of analyze and backup THE WHOLE machine, that is not true (being backup generally few tens MB tgz).
Where am I wrong ?

If you use the “Add Custom Directory” option and put /home/myfolder in the field, the backup will include that directory and contents.

When it restores, it restores it back to that path on the new system.

My fault, perhaps you mean " add /home/myfolder " to custom files section in backup configuration…
Ok, fine, but what if I haven’t a custom folder ? can i simply put the script (asterisk owned) into __ASTETCDIR__to be restored ?

__ASTETCDIR__ is set by default as a file path to backup. So if your files are in there and you don’t remove that setting from the backup, it will be backed up and restored as it should.

That’s what I need,