-
Notifications
You must be signed in to change notification settings - Fork 279
N°8458 - Improve backup/restore mechanisms #719
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: support/3.2
Are you sure you want to change the base?
Conversation
|
Hello, thank you for your PR ;) Concerning the use of the system temp folder, this is the way we did it first in iTop, before finally setting it to data folder, because some people met permissions issues. I think the best way would be to have an option parameter that would allow choosing the desired path to store the temporary backup file, with the default value being the current one (in data folder). That would also allow choosing another disk or VM for example. On my side I'll open an internal ticket, to clean the temporary backup when creating a new one, since there is generally no point of keeping them. |
If that would be really the case, all the other uses of It is really bad practice to use app/data directories for temporary files (disk wear, disk speeds, ...) hence this is why specific temp dirs exist in Linux systems. About having an option for that, do you mean it to be specific for backups or for all uses of
What do you mean with that? Under normal circumstances the tmp files are removed after backup creation. This only didn't happen when encountering errors, this should now be solved by moving this removal to the |
Well, that's the point. Some iTops are not installed on Linux. And some are installed on Linux with some weird configurations. Even if we don't have to support the systems configurations of our users, we found a solution that works in most of the environments. You could also say the same thing for the logs - that could/should be written in /var/log - but the choice has been mode to store them inside iTop folder.
It was specific to the backups.
Yes, it should, indeed. I'll test it. |
|
@odain-cbd Why did You close this PR? And why did you remove the 3.2 branch? |
Sorry for this. Branch was removed by mistake. Lucky me ...github only closes the attached PRs. It could have bébé worst! |
|
@odain-cbd please reopen the PR |
|
@jf-cbd I made it into an config option, this gives indeed more flexibility. Default stays |
|
@jf-cbd Archive_Tar has been updated to 1.6.0 which includes checks for correct writing to the file.. Do you expect anything else from me? |
|
Hello @Hipska, thanks for your edition :) It sounds good to me. I'll do some tests and keep you updated. |
|
I have an additional use-case where the disk on |
# Conflicts: # composer.lock # lib/composer/installed.php
Co-authored-by: jf-cbd <[email protected]>
| public static function GetTmpDir(Config $oConfig): string | ||
| { | ||
| $sTmpDir = @tempnam($oConfig->GetModuleSetting('itop-backup', 'backup_tmpdir', 'data/') , 'itop-backup-'); | ||
| unlink($sTmpDir); // I need a directory, not a file... | ||
| SetupUtils::builddir($sTmpDir); | ||
|
|
||
| return $sTmpDir; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| public static function GetTmpDir(Config $oConfig): string | |
| { | |
| $sTmpDir = @tempnam($oConfig->GetModuleSetting('itop-backup', 'backup_tmpdir', 'data/') , 'itop-backup-'); | |
| unlink($sTmpDir); // I need a directory, not a file... | |
| SetupUtils::builddir($sTmpDir); | |
| return $sTmpDir; | |
| } | |
| public static function GetTmpDir(Config $oConfig): string | |
| { | |
| $sTmpDirConfig = $oConfig->GetModuleSetting('itop-backup', 'backup_tmpdir', 'data/'); | |
| if (Utils::IsNullOrEmptyString($sTmpDirConfig) || $sTmpDirConfig === 'data/' || $sTmpDirConfig === 'data') { | |
| $sTmpDir = APPROOT.'data/itop-backup'; | |
| } else { | |
| if (!is_dir($sTmpDirConfig)) { | |
| throw new InvalidParameterException("The configured temporary backup directory '$sTmpDirConfig' is not a valid directory."); | |
| } | |
| $sTmpDir = @tempnam($sTmpDirConfig, 'itop-backup-'); | |
| @unlink($sTmpDir); // I need a directory, not a file... | |
| } | |
| SetupUtils::builddir($sTmpDir); | |
| return $sTmpDir; | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will make the tests pass and warn the user in case of wrong config
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't return a unique temporary directory in some (default) cases.
It also removes to option to use PHP's temporary directory without needing to specify it also in the iTop config file.
# Conflicts: # datamodels/2.x/itop-backup/backup.php # datamodels/2.x/itop-backup/module.itop-backup.php # tests/php-unit-tests/src/BaseTestCase/ItopTestCase.php # tests/php-unit-tests/unitary-tests/setup/DBBackupDataTest.php
Base information
Symptom (bug) / Objective (enhancement)
To have better reliability when issues occur when creating/restoring backup.
Reproduction procedure (bug)
These are different scenarios when problems might arise:
data/while there is more than enough in system temporary directory.Proposed solution (bug and enhancement)
Checklist before requesting a review
Checklist of things to do before PR is ready to merge