Python Forum
How to take the tar backup files form remote server to local server
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to take the tar backup files form remote server to local server
#1
import os, subprocess, psutil
import sys
import tarfile
COMMAND="ls -la"

HOST=input("Please enter old server: ")

ssh_option="-o StrictHostKeyChecking=no"
ssh = subprocess.Popen(["ssh", ssh_option,"%s" % HOST, COMMAND],shell=False,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
result = ssh.stdout.readlines()
if result == []:
error = ssh.stderr.readlines()
print >>sys.stderr, "ERROR: %s" % error
print(" if test")
else:
COMMAND1=subprocess.call(['python tartest.py']) #i what to run command script on remote server and take backupfiles in to local server
ssh_tar_baekup = subprocess.Popen(["ssh", ssh_option,"%s" % HOST,COMMAND1],shell=True,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
-----------------------
cat tartest.py
import os
import subprocess
from contextlib import closing
import sys
import tarfile
with closing(tarfile.open("/var/tmp/back_siva/siva.tar.gz","w:gz")) as tar:
for file in ["/var/tmp/back_siva/yp.conf","/var/tmp/back_siva/ypserv.conf"]:
tar.add(os.path.basename(file))
-----------------------------------------------

Please enter old server: xxxxxx
Traceback (most recent call last):
File "testsiva1.py", line 17, in <module>
COMMAND1=subprocess.call(['python tartest.py'])
File "/usr/lib64/python2.7/subprocess.py", line 524, in call
return Popen(*popenargs, **kwargs).wait()
File "/usr/lib64/python2.7/subprocess.py", line 711, in __init__
errread, errwrite)
File "/usr/lib64/python2.7/subprocess.py", line 1327, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  501 Server cannot accept argument anna17 0 189 Apr-11-2024, 01:08 AM
Last Post: anna17
  Unable to connectDjango to mysql server sureshpython 0 175 Apr-09-2024, 07:30 PM
Last Post: sureshpython
Question [SOLVED] Tiny web server as standalone executable? Winfried 0 338 Feb-09-2024, 11:48 AM
Last Post: Winfried
  Triggering a ps1 script in remote windows server via http python request jasveerjassi 1 374 Jan-26-2024, 07:02 PM
Last Post: deanhystad
  How to Connect to PostgreSQL Through Jump Server and SSH Tunnel using Python? nishans 1 998 Jan-02-2024, 10:37 AM
Last Post: khanzain
  uploading files from a ubuntu local directory to Minio storage container dchilambo 0 460 Dec-22-2023, 07:17 AM
Last Post: dchilambo
  Run python app on IIS web server adevendr 1 803 Aug-14-2023, 01:02 PM
Last Post: snippsat
  Timestamp of file changes if a share mapped to a server…. tester_V 34 3,949 Jul-04-2023, 05:19 AM
Last Post: tester_V
  Networking Issues - Python GUI client and server connection always freezes Veritas_Vos_Liberabit24 0 733 Mar-21-2023, 03:18 AM
Last Post: Veritas_Vos_Liberabit24
  connecting to FTPS server help tfboy 2 2,655 Feb-23-2023, 10:31 AM
Last Post: tfboy

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020