$config['system']['remotebackup']['GDriveBackupCount'] = 30; } if ($_POST['GDrivePasswordConfirm'] != $_POST['GDrivePassword']) { // log error, but continue $input_errors[] = gettext("The supplied 'Password' and 'Confirm' field values must match."); } if (is_uploaded_file($_FILES['GDriveP12file']['tmp_name'])) { $data = file_get_contents($_FILES['GDriveP12file']['tmp_name']); $config['system']['remotebackup']['GDriveP12key'] = base64_encode($data); } elseif ($config['system']['remotebackup']['GDriveEnabled'] != "on") { unset($config['system']['remotebackup']['GDriveP12key']); } write_config(); // test / perform backup try { $filesInBackup = backup_to_google_drive(); $cron_job = "/usr/local/opnsense/scripts/remote_backup.php"; if (!cron_job_exists($cron_job)) { // initial cron job install install_cron_job($cron_job, true, 0, 1); } } catch (Exception $e) { $filesInBackup = array(); } if (count($filesInBackup) == 0) { $input_errors[] = gettext("Google Drive communication failure"); } else { $input_messages = gettext("Backup succesfull, current filelist:"); foreach ($filesInBackup as $filename => $file) { $input_messages = $input_messages . "<br>" . $filename; }
#!/usr/local/bin/php <?php /** * Backup to Google Drive (if configured) */ require_once "util.inc"; require_once "config.lib.inc"; backup_to_google_drive();