\x89PNG\r\n\x1a\n\x00\x00\x00\x0DIHDR\x00\x00\x00\x01\x00 \x00\x00\x01\x08\x06\x00\x00\x00\x1F\x15\xC4\x89\x00\x00\x00 \x0AIDATx\x9Ccb\x00\x00\x00\x06\x00\x03\x1A\x05\x9D\x00\x00 \x00\x00IEND\xAE\x42\x60\x82
| Path : /var/www/html/yedekledb24/DatabaseBackupMasterv4/__pycache__/ |
|
B-Con CMD Config cPanel C-Rdp D-Log Info Jump Mass Ransom Symlink vHost Zone-H |
| Current File : /var/www/html/yedekledb24/DatabaseBackupMasterv4/__pycache__/storage_utils.cpython-310.pyc |
o
�-�g�K � @ s� d dl Z d dlZd dlZd dlZd dlmZ d dlmZ d dlmZ d dlZdZ zd dl
ZdZ W n eyC e�
e�Ze�d� Y nw dZzd dlZdZW n eya e�
e�Ze�d� Y nw e�
e�Zd d
� Zdd� Zd
d� ZdS )� N)�datetime)�FTP)�
SMBConnectionFTz;NFS support not available - nfs4-share module not installedz:SFTP support not available - paramiko module not installedc C s� �z3| dkrKt ||d|dd�}|du rd}|�||�}|s W dS |�� }dd � |D �} |�d
�d }
|
| vrDt�d|
� d
| � �� W dS |�� W dS | dkr�tsYt�d� W dS z't� � }t
j|dd�}|�|�}
|
�
|�}t�|� |�� t�|� W W dS ty� } zt�dt|�� �� W Y d}~W dS d}~ww | dkr�|du r�d}t� }|�||� |�||� |r�|�|� |�� W dS | dk�r*ts�t�d� W dS |du r�d}z/t�� }|�t�� � |j||||d� |�� }|r�|�|� |�� |�� |�� W W dS t�y) } zt�dt|�� �� W Y d}~W dS d}~ww t�d| � �� W dS t�yX } zt�d| � d|� dt|�� �� W Y d}~dS d}~ww )a�
Test connection to a storage target.
Args:
storage_type (str): Storage type (smb, nfs, ftp)
host (str): Storage host
port (int): Storage port
username (str): Username for storage
password (str): Password for storage
path (str): Storage path
Returns:
bool: True if connection successful, False otherwise
�smb�
backup-appT��use_ntlm_v2N� Fc S s g | ]}|j �qS � )�name)�.0�sharer
r
�?/var/www/html/yedekledb24/DatabaseBackupMaster/storage_utils.py�
<listcomp>B s z+test_storage_connection.<locals>.<listcomp>�/r zShare z not found in available shares: �nfs�>NFS support is not available - nfs4-share module not installed�tcp��protozNFS connection error: �ftp� �sftp�=SFTP support is not available - paramiko module not installed� ��hostname�port�username�passwordzSFTP connection error: �Unsupported storage type: zStorage connection error for � �: )r �connect�
listShares�split�logger�error�close�NFS_SUPPORT�tempfile�mkdtemp�nfs4�
NFS4Client�
get_export�mount�os�listdir�umount�rmdir� Exception�strr �login�cwd�quit�SFTP_SUPPORT�paramiko� SSHClient�set_missing_host_key_policy�
AutoAddPolicy� open_sftp�chdir)�storage_type�hostr r r �path�conn� connected�shares�share_names�
share_name� mount_dir�client�exportr/ �er �sshr r
r
r �test_storage_connection s� �
��
�
�� ��rM c
C s� �z�| j dkrLt| j| jd| jdd�}| jdur| jnd}|�| j|�}|s*td��| j� d�d }|�
|�}|�� |j|j
}|j|j
}||fW S | j d
kr�ts[t�d� W dS z7t�� }tj| jd
d�} | �| j�}
|
�|�}t�|�}|�� t�|� |j|j }|j|j }||fW W S ty� }
zt�dt|
�� �� W Y d}
~
W dS d}
~
ww | j dk�rzB| jdur�| jnd}t � }|�| j|� |�!| j| j� z|�"d�}t#|� � d �}|d }W n d}d}Y |�$� ||fW W S t�y }
zt�dt|
�� �� W Y d}
~
W dS d}
~
ww | j dk�r�t%�s*t�d� W dS zo| jdu�r4| jnd}t&�'� }|�(t&�)� � |j| j|| j| jd� d| j� d�}|�*|�\}}}|�+� �,� �-� }|�r�|� � }t.|�dk�r�t#|d �d }t#|d! �d }|�� ||fW W S |�� d}d}||fW W S t�y� }
zt�d"t|
�� �� W Y d}
~
W d#S d}
~
ww t�d$| j � �� W dS t�y� }
zt�d%| j/� d&t|
�� �� W Y d}
~
dS d}
~
ww )'z�
Get available and total space for a storage target.
Args:
storage (StorageTarget): Storage target object
Returns:
tuple: (free_space, total_space) in bytes
r r Tr Nr �Could not connect to SMB sharer r r r )i @l
r r zError getting NFS space: )r � r r zAVBL /rO � � �>� b zError getting FTP space: r r r r z df -P -k z
| tail -1� i � zError getting SFTP space: )rQ rR r z Error getting storage space for r"