Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Looking for a Archive/Backup script that accepts arguments called from the command line

$
0
0

The aim is a PowerShell script solution. This script is triggered by various means configured in a third party application.

The script will also clear time-controlled files or archive (hereafter used only archiving), which directories should never be deleted.
 

The file formats should be considered as flexible are passed as parameters. With multiple file formats can be accepted.
 

Reference and archive directory should be freely chosen.


The depth of the directories that should be considered to be freely chosen.

3.1 Time Control
An additional parameter is passed a value in the format <integer> with the unit [days]. "Hay-te" +} {DAY returns the date to be archived for up to date modified files.


The depth of the directories that should be considered to be freely chosen.

3.2 File format (s)
An additional parameter is a value in the fromat <string> = [*.* | *. txt, * log | | *. log | *. txt, etc.] passed to the script that determines which file formats to consider.

Several file formats Comma Separated passed. The case sensitivity of file extensions may not play a role. I.e. a file with the extension *. log is treated as a file with the extension *. log or *. log.

Thus fell in the choice of the value to pass to the upper and lower case.

3.3 recursivity
An additional parameter is a value in the format defined <integer> = [0 | 1 s | | ...], to consider how far into the directory structure of the script files.

With the value "0" only files from the directory reference is taken into account.

I.e. 0th = Reference level directory

3.4 Deletion / Archiving
An additional parameter is a value in the format given without units = <integer> the script [0 | 2 | 1].

Here, the values ​​should be interpreted as follows:
0: Delete the files
1: Archiving files without compression
2: Archiving files with compression

Principle must be created if no archive to archive any files.

3.4.1 0: Deleting the files
All relevant files are deleted from the reference list, and recursively definitely in the specified depth.

3.4.3 1: Archiving files without compression
All relevant files are copied along with the directory structure to an archive directory and deleted the reference list.

Here is the list of reference be extended to the archive directory with the prefix "ARCHIVE_" and then in date format "_yyyymmdd-hhmm".


example:
Reference directory ... = \ Logs \
Archive directory ... = \ Archive directory
Recursive = 1

The result:
- Lists of the second Level have been excluded
- Reference list was supplemented with prefix and date

3.4.4 1: Archiving files with compression
In contrast to the archive without compression should be in this case, the directory containing their files archived. What type of compression is used, is optional.

3.5 Reference Guide
An additional parameter is passed a value <string> fromat in the script. This string contains a complete blank signless path to the directory to be archived.
The directory must be both local (C: \ ...) and network paths (\ \ ...) are supported.


3.6 archive directory
An additional parameter is passed a value <string> fromat in the script. This string contains a complete blank signless path to the destination directory into which the archive should be created.
The directory must be both local (C: \ ...) and network paths (\ \ ...) are supported.


4th
Structure of the call

1 2 3 4 5 6 7
ArchiveScript.sc 2 -30 9 *. log, *. txt, *. xml C: \ BelVis \ Logs \ \ srv1 \ Archive

1: Name of script
2: Function
3: Time Control
4: recursivity
5: File format (s)
6: Reference Guide
7: Archive directory


Viewing all articles
Browse latest Browse all 6937

Trending Articles