56 lines
1.9 KiB
Python
Executable File
56 lines
1.9 KiB
Python
Executable File
#! /home/jonnybravo/Projekte/Python_Skripte/rclone/bin/python3.11
|
|
|
|
import os, time
|
|
|
|
|
|
|
|
def check_ping(hostname = str):
|
|
response = os.system("ping -c 1 " + hostname)
|
|
# and then check the response...
|
|
if response == 0:
|
|
return True
|
|
else:
|
|
return False
|
|
|
|
|
|
def rclone_folders_copy(folder_to_sync=list, dest_folder = str):
|
|
check_list = []
|
|
for sync_folder in folder_to_sync:
|
|
print("Hole Datein", 'rclone:' + sync_folder, "...")
|
|
command = os.system('rclone copy rclone:' + sync_folder + ' ' + dest_folder + os.sep + sync_folder +' --update --create-empty-src-dirs &> /dev/null')
|
|
if command == 0:
|
|
check_list.append(True)
|
|
elif command > 0:
|
|
check_list.append(False)
|
|
print("Folder", "rclone:" + sync_folder , "not exist")
|
|
print("Kopiere Datein", dest_folder + os.sep + sync_folder, "..." )
|
|
command = os.system('rclone copy ' + dest_folder + os.sep + sync_folder + ' ' + "rclone:" + sync_folder + ' --update --create-empty-src-dirs &> /dev/null' )
|
|
if command == 0:
|
|
check_list.append(True)
|
|
elif command > 0:
|
|
check_list.append(False)
|
|
print("Folder", dest_folder + os.sep + sync_folder , "not exist")
|
|
for check in check_list:
|
|
if check is False:
|
|
return False
|
|
return True
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
folder_to_sync_manuell = ['ssh_keys', 'frei', 'Doku','Joplin', 'Hack']
|
|
print("Check online status")
|
|
for check_count in range(1,10):
|
|
print(check_count)
|
|
# if check_ping(hostname="schlaubistechtalk.de") is True:
|
|
# break
|
|
print("Lauf", check_count, "warte 10 Sekunden..",sep=" ")
|
|
time.sleep(2)
|
|
|
|
if rclone_folders_copy(folder_to_sync=folder_to_sync_manuell, dest_folder="/home/jonnybravo/.nextcloud") is True:
|
|
print("Sync erfolgreich")
|
|
else:
|
|
print("Sync nicht erfolgreich !!")
|
|
|
|
|