--- sidebar_position: 8 --- # Backups Manage backup jobs, destiantions, exclude lists, restore, etc. ## Backup Jobs To list all current backup jobs run command: ```bash opencli backup-job list ``` ### Create a job ```bash opencli backup-job create ``` ### Edit backup job ```bash opencli backup-job edit ``` ### Run backup job ```bash opencli backup-run --force-run ``` ### Delete backup job ```bash opencli backup-job delete ``` ## Destination To list all current destinations run command: ```bash opencli backup-destination list ``` Example output: ```bash Available destination IDs: 2143 2145 2142 2144 2141 ``` ### Add Destination To create a new destination run the following command: ```bash opencli backup-destination create ``` Example: ```bash opencli backup-destination create 15.19.90.29 strongpass 22 root /root/.ssh/id_rsa 85 ``` ### Edit Destination To edit destination configuration run the following command: ```bash opencli backup-destination edit ``` Example: ```bash opencli backup-destination edit 241 15.19.90.29 strongpass 22 root /root/.ssh/id_rsa 85 Destination ID: '241' edited successfully! Previous destination configuration: { "hostname": "18.19.90.29", "password": "pass222", "ssh_port": 22, "ssh_user": "new_ssh_user", "ssh_key_path": "/root/.ssh/id_rsa", "storage_limit": "100" } New destination configuration: { "hostname": "15.19.90.29", "password": "strongpass", "ssh_port": 22, "ssh_user": "root", "ssh_key_path": "/root/.ssh/id_rsa", "storage_limit": "85" } ``` ### Delete Destination To delete a destination run the following command: ```bash opencli backup-destination delete ``` :::tip Destination can not be deleted if it is used by any backup job. ::: ### Validate Destination To validate a destination run the following command: ```bash opencli backup-destination validate ``` Command will test; - if ssh key exists and its permissions - ssh connection to the destination server - check if destination folder exists - check permissions and owner for destination folder - check available disk space on destination and compare it with storage limit Examples: ```bash opencli backup-destination validate 2144 Validating SSH connection with the destination, running command: 'ssh -i /root/.ssh/id_rsa root@18.19.90.29 -p 22' SSH connection successful. Destination directory /root/backup on the remote server is owned by root user. Disk usage on remote destination is over the storage limit (70%) for /root/backup. Backups jobs will not run! ``` ```bash opencli backup-destination validate 2145 Validating SSH connection with the destination, running command: 'ssh -i /root/.ssh/id_rsa root@18.19.90.29 -p 22' SSH connection successful. Destination directory /root/backup on the remote server is owned by root user. Disk space on remote destination is below the storage limit (85%) for /root/backup. Backups can run without a problem. ``` ```bash opencli backup-destination validate 1 Validating SSH connection with the destination, running command: 'ssh -i /root/.ssh/id_rsa root@18.19.90.29 -p 202' ssh: connect to host 18.19.90.29 port 202: Connection refused Validation failed! SSH connection failed or timed out. SSH Connection Status: 255 ``` ## Restore ### Full Account restore To restore user files from a backup run command: ```bash opencli backup-restore --all ``` ### Partial restore To restore only specific files from a backup, specify what to restore instead of the `--all` flag: ```bash opencli backup-restore [-files --entrypoint --nginx-conf --mysql-conf --mysql-data --php-versions --crontab --user-data --core-users --stats-users --apache-ssl-conf --domain-access-reports --ssh --timezone] ``` Available options: - `--all` - restores all user files. - `--files` - restores home directory - `--entrypoint` - restore services and their status - `--apache-conf` - restore Apache configuration - `--nginx-conf` - restore Nginx configuration - `--mysql-conf` - restore MySQL configuration - `--mysql-data` - restore MySQL databases and users - `--php-versions` - restore php versions and their php.ini files - `--crontab` - restore cronjobs - `--user-data` - restore user password, email address, 2fa settings, preferences.. - `--core-users` - restore OpenPanel data for the user account - `--stats-users` - restore resource usage statistics for the account - `--apache-ssl-conf` - restore VirtualHosts and SSL certificates - `--domain-access-reports` - restore html reports for domain visitors - `--ssh` - restore SSH users and passwords - `--timezone` - restore timezone setting ## List Backups for user `opencli backup-list` allows you to view available backups for a single user. ```bash opencli backup-list [--json] ``` ## View backup details `opencli backup-details` allows you to view information about a specific user backup. ```bash opencli backup-list [--json] ``` Example: ```bash root@server:/# openpanel backup-details nesto 2 20240131170700 backup_job_id=2 destination_id=1 destination_directory=20240131170700 start_time=Wed Jan 31 17:07:52 UTC 2024 end_time=Wed Jan 31 17:09:35 UTC 2024 total_exec_time=103 contains=Full Backup status=Completed ``` ## Index `opencli backup-index` allows you to re-index backups from a remote destination and make them available for users. ```bash opencli backup-index ``` Example: ```bash opencli backup-index 21 Indexing backups for 5 users from destination: 18.19.90.29 and directory: /root/backup Processing user stefan (1/5) Indexed 6 backups for user stefan. Processing user demo (2/5) Indexed 6 backups for user demo. Processing user demo123 (3/5) Indexed 6 backups for user demo123. Processing user pera (4/5) Indexed 5 backups for user pera. Processing user nesto (5/5) Indexed 5 backups for user nesto. Index complete, found a total of 28 backups for all 5 users. ``` ## Check `opencli backup-check` checks process id for any running jobs and terminates the backupjob if process is not running. ```bash opencli backup-check ``` ## Logs ### List Logs ### View Log File ### Delete Log File ## Scheduler `opencli backup-scheduler` command is executed daily to schedule new backup jobs and ensure they are carried out on time. Example: ```bash opencli backup-scheduler --debug 0 1 * * SUN opencli backup-run 2 --entrypoint --files --mysql_conf 0 1 * * * opencli backup-run 3 --conf ``` ## Config `opencli backup-config` allows you to change general backup settings that affect all backup jobs and destinations. ### Get The `get` parameter allows you to view current backup settings. ```bash opencli backup-config get