forked from LondheShubham153/python-masterclass
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsystem_utils.py
More file actions
29 lines (22 loc) · 831 Bytes
/
Copy pathsystem_utils.py
File metadata and controls
29 lines (22 loc) · 831 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import shutil
import datetime
import os
def backup_files(source, destination):
today = datetime.date.today()
backup_name = os.path.join(destination, f"backup_{today}.tar.gz")
try:
shutil.make_archive(backup_name.replace('.tar.gz', ''), 'gztar', source)
print(f"Backup created successfully: {backup_name}")
except Exception as e:
print(f"Error creating backup: {e}")
def check_disk_space():
disk_status = os.system('df -h')
return disk_status
def check_cpu_load():
cpu_load = os.system('uptime')
return cpu_load
check_disk_space()
check_cpu_load()
source_dir = "/Users/shubham/Documents/work/TrainWithShubham/python-workshop/practice"
destination_dir = "/Users/shubham/Documents/work/TrainWithShubham/python-workshop/practice"
backup_files(source_dir, destination_dir)