File manager - Edit - /usr/local/CyberCP/plogical/__pycache__/backupSchedule.cpython-310.pyc
Back
o �h�N � @ s@ d dl Zd dlZd dlZej�d� ej�dd� e�� d dl m Z d dlZd dl Z d dlZd dlZd dlmZ d dlmZmZmZ d dlmZmZmZ d d lmZ d d lmZ d dlZd dlZd dlmZ d dl Z G dd � d �Z!dd� Z"dd� Z#e$dkr�e%dd�D ]Z&e&dks�e&dks�e&dkr�q�e � e&e#� q�e"� dS dS )� Nz/usr/local/CyberCP�DJANGO_SETTINGS_MODULEzCyberCP.settings)�CyberCPLogFileWriter)�backupUtilities)�match�I�M)�Backups� BackupJob� BackupJobLogs)�ProcessUtilities)�randint)�datetimec @ sn e Zd Ze�� ZdZdZdZdZdZ dZ eddd��Zedd� �Z eddd��Zedd d��Zedd� �ZdS )�backupScheduler � � z /home/cyberpanel/remoteBackupPIDc C s� zFt | d�}|�dt�d� d | d � tdt�d� d | d � |�� tjdkr1W d S ttj|dt�d� d | d�� � W d S t yY } zW Y d }~dS d }~ww ) N�a�[�%m.%d.%Y_%H-%M-%Sz] � r )�owner�status�messagezCan not write to error file.)�open� writelines�time�strftime�print�closer � backupLogr �save�IOError)�fileNamer r �file�msg� r$ �-/usr/local/CyberCP/plogical/backupSchedule.py�remoteBackupLogging s ,��z"backupSchedule.remoteBackupLoggingc C s$ �z�t �|d| � ttdd��}d| }t|d�}|�� t�� }t� || d��}t jd| |dd �}tj �tj�rBtj�|j� t�|j�}|d } t �|d� t�d� d | } d} | }tj �d|d�} tj �d|d�}tj �d|d�}z t|d��� }W n d}Y t�d�}tj �d�r�d| }tj�|� |�d�dks�|�d�dk�r�|�d| ��r�tj �d�r�d}tj�|� tj �| ��r�tj �d�r�d}tj�|� t| d��� } t�d� | �d �dk�rd!| }t�|� d!| }t�|� d!| }t�|� t �|d"| � zt�|� W n Y d| fW S | �d#�dk�r�tj �d��r6d$}tj�|� z7d!| }t�|� d!| }t�|� d!| }t�|� d%| }t�|� tjj|d&�}|D ]}|� � �qdW n Y t �|d'| | f t j!� zt�|� W n Y d%| }t�|� d| fW S tj �| ��r�tj �d��r�d(}tj�|� t �|d)t| d��� t j!� t�| � d%| }t�|� W d*S �ntj �d��r�d+}tj�|� tj �| ��rttj �d��r�d,}tj�|� t| d��� } t�d� | �d �dk�r=d!| }t�|� d!| }t�|� d!| }t�|� t �|d"| � zt�|� W n Y d| fW S tj �| ��rstj �d��rSd-}tj�|� t �|d)t| d��� t j!� t�| � d%| }t�|� W d*S nltj �d��r�d.}tj�|� |dk�r�tj �d��r�d/}tj�|� d%| }t�|� W d0S tj �| ��r�tj �d��r�d1}tj�|� t �|d)t| d��� t j!� t�| � d%| }t�|� W d*S t�d2� d}q^ t"�y } z$tj�t|�d3 � t �|d'| t|�f t j!� dt|�fW Y d }~S d }~ww )4NzStarting local backup for: i ʚ;l �c( z/home/cyberpanel/zw+)� randomFile�websiteToBeBackedz)https://localhost:%s/backup/localInitiateF)�data�verify�tempStoragez!Waiting for backup to complete.. � z/home/cyberpanel/%s-backup.txtr r �/homez backup/statuszbackup/backupFileNamez backup/pid�rz Fetching..�ps auxz/usr/local/CyberCP/debugz<Output of px aux when running remote backup status check: %s�startBackup���� BackupRootz/%s/zIf running found.z(If running found. and status file exists� � Completedzsudo rm -f zBackup Completed for: z[5009]z.If running found. status file exists but errorz rm -rf %s)r! z6Local backup creating failed for %s, Error message: %szMIf running found. status file exists, scheduler path also exists hence killedz Backup process killed. Error: %s)r zBackup process killed.zIf running not found.z(if running not found, Status file existszLif running not found, Status file exists, scheduler path exists thus killed.zStatus file does not exists.zOif running not found, Status file does not exists, kill counter 1, thus killed)r z8Backup process killed without reporting any error. [184]zSif running not found, Status file does not exists, scheduler path found thus killed� z [119:startBackup])#r r&