Examples of compressing Multiple folders using the rar command in python in windows

Source: Internet
Author: User

Copy codeThe Code is as follows:
#! /Usr/bin/env python
# Filename: backup_ver1.py

Import OS
Import time

#1. The files and directories to be backed up are specified in a list.
# Source = ['/home/swaroop/byte','/home/swaroop/bin']
Source = ['d: \ FileCopier \ *. * ', 'd: \ jeecms_doc \ *. *']
# If you are using Windows, use source = [r 'C: \ users', r 'd: \ work'] or something like that

#2. The backup must be stored in a main backup directory
# Target_dir = '/mnt/e/backup/' # Remember to change this to what you will be using
Target_dir = 'e: \ temp \ '# Remember to change this to what you will be using

#3. The files are backed up into a zip file
#4. The name of the zip archive is the current date and time
Target1_target_dir1_time.strftime('policy?m=d=h?m=s'{}'.zip'

#5. We use the zip command (in Unix/Linux) to put the files in a zip archive
# Zip_command = "zip-qr '% s' % s" % (target, ''. join (source ))
Zip_command = "rar a" + target + ''. join (source)
# Run the backup
If OS. system (zip_command) = 0:
Print 'successful backup to', target
Else:
Print 'backup failed'

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.