Code Monkey home page Code Monkey logo

sync-directory's Introduction

Backup using robocopy

Sync directorys and put extra/old files in other folder structure. Extra files older then x days is purged from the "extra" folder.

Uses robocopy

Functions

  • Sync files/shares between computers.
  • "old" files on target moved to extra folder
  • "old" files removed after x months
  • Log Fullname/path - Total size - Total num
    • New files copied
    • Old files moved
    • Old files removed

Logging

  • File dump
  • Windows Eventlog
  • Console

Example

.\sync-directory.ps1 -Path \\pihl-fs\Pihl\ -Destination D:\Backup\Documents\ -DestinationExtraFiles D:\Backup\BackupPihl-ExtraFiles\ -Verbose

Result

Result


Requires

#Requires -RunAsAdministrator
#Requires -Modules Microsoft.PowerShell.Management

Synopsis

.SYNOPSIS
    Sync directories and put extra/old files in other folder structure.
    Extra files older then x days is purged from the "extra" folder.

    Uses robocopy
.DESCRIPTION
    Steps;
        1. Removes empty directories and files older then defined days
        2. Moves files on destination not existing on source to another directory
        4. Move earlier versions of files with added date in filename
        3. Syncs files, do not purge extra files.

    Logging to files;
    Date_Old.log
    Date_Extra.log
    Date_Sync.log
    Date_Error.log

.EXAMPLE
    Sync documents on fileserver to External disk D:
    .\sync-directory.ps1 -Path \\pihl-fs\Pihl\ -Destination D:\Backup\Documents\ -DestinationExtraFiles D:\Backup\BackupPihl-ExtraFiles\ -Verbose

.PARAMETER Path
    Source directory

.PARAMETER Destination
    Target directory

.PARAMETER DestinationExtraFiles
    Target directory of file and folders removed from source since previous sync

.PARAMETER PurgeAge
    Age of files before removed from 'extra' folder

.PARAMETER LoggingPath
    Logging directory

.OUTPUTS
    Logs to Eventlog, files and console
.NOTES

    If source path is empty or wrong target all files in destiantion is moved to the 'extra files' directory.
    Requires to be run as administrator for robocopys 'audit' function to work on getting extra files.
    2021-02-08 Version 0.9 Proof of concept with major bug.
    2022-04-10 Version 1.0 Working backup of files.

.LINK
    https://github.com/KlasPihl

sync-directory's People

Contributors

klaspihl avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.