sebastianfeldmann / phpbu

PHP Backup Utility - Creates and encrypts database and file backups, syncs your backups to other servers or cloud services and assists you monitor your backup process
https://phpbu.de
Other
1.29k stars 110 forks source link

zip Compression #351

Open rohan-nitsan opened 9 months ago

rohan-nitsan commented 9 months ago

I used the zip compression technique.

But the compressed file was saved with only .tar. It's working fine with gzip and bzip2 compression.

I also get an error in the generated log

"errors": [
        {
            "class": "RuntimeException",
            "message": "Command failed:\n  exit-code: 3\n  message:   \n",
            "file": "phar:\/\/\/var\/www\/html\/typo3conf\/ext\/ns_backup\/phpbu.phar\/lib\/sf-cli\/Command\/Runner\/Simple.php",
            "line": 57
        }
    ],

Here is my configuration json

{
  "verbose": true,
  "debug": false,
  "logging": [
    {
      "type": "json",
      "target": "/var/www/html/rohan/uploads/tx_nsbackup/json/test_fileadmin_log.json"
    },
    {
      "type": "mail",
      "options": {
        "transport": "mail",
        "recipients": "rohan.nitsan@gmail.com",
        "subject": "[fileadmin] Test - NS Backup Email",
        "sendOnlyOnError": "0"
      }
    }
  ],
  "backups": [
    {
      "name": "27112023_1333_Test",
      "source": {
        "type": "tar",
        "options": {
          "path": "/var/www/html/fileadmin"
        }
      },
      "target": {
        "dirname": "/var/www/html/rohan/uploads/tx_nsbackup/fileadmin",
        "filename": "fileadmin-%Y%m%d-%H%i.tar",
        "compress": "zip"
      },
      "cleanup": {
        "type": "quantity",
        "options": {
          "amount": "2"
        }
      }
    }
  ]
}

Generated json log

{
    "status": 1,
    "timestamp": 1701092018,
    "duration": 0.0447,
    "backupCount": 1,
    "backupFailed": 1,
    "errorCount": 1,
    "errors": [
        {
            "class": "RuntimeException",
            "message": "Command failed:\n  exit-code: 3\n  message:   \n",
            "file": "phar:\/\/\/var\/www\/html\/typo3conf\/ext\/ns_backup\/phpbu.phar\/lib\/sf-cli\/Command\/Runner\/Simple.php",
            "line": 57
        }
    ],
    "backups": [
        {
            "name": "27112023_1333_Test",
            "status": 1,
            "checks": {
                "executed": 0,
                "failed": 0
            },
            "crypt": {
                "executed": 0,
                "skipped": 0,
                "failed": 0
            },
            "syncs": {
                "executed": 0,
                "skipped": 0,
                "failed": 0
            },
            "cleanup": {
                "executed": 0,
                "skipped": 0,
                "failed": 0
            }
        }
    ],
    "debug": [
        "\/usr\/sbin\/tar -cf '\/var\/www\/html\/rohan\/uploads\/tx_nsbackup\/fileadmin\/fileadmin-20231127-1333.tar' -C '\/var\/www\/html' 'fileadmin'",
        "exception: Command failed:\n  exit-code: 3\n  message:   \n"
    ]
}
sebastianfeldmann commented 9 months ago

Exit code 3 happens when a file is changed during the backup process. You can add the ignoreFailedRead option to your config and set it to true. This is of course risky and you should check your backups regularly :)

The zip issue is, that depending on your OS zip is not available. phpbu will always create tars so your backup becomes a single file to move around. Especially if your backup source is a directory.

rohan-nitsan commented 9 months ago

Hi @sebastianfeldmann,

Thanks for your answer. I tried the ignoreFailedRead configuration, but still i got the same error.

Here is my json configration

"source": {
    "type": "tar",
    "options": {
        "ignoreFailedRead": true,
        "path": "/var/www/html/fileadmin"
    }
}