Last active
September 17, 2018 13:30
-
-
Save robie2011/54fd58dbcaad97b6105ab7838c92e4ea to your computer and use it in GitHub Desktop.
SymmetricDS FileSynchronization Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Set-Location C:\report-collection | |
$errors = 0 | |
$ok = 0 | |
Get-ChildItem *random* | ForEach-Object { | |
$_.Name -match '\d+_random_md5_(\w+)\.txt' | out-null | |
if ($matches[1] -ne (Get-FileHash $_.Name -Algorithm md5).Hash) { | |
$errors += 1 | |
} else { | |
$ok += 1 | |
} | |
} | |
Write-Host "errors=$errors, ok=$ok" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
begin tran | |
delete from sym_file_trigger_router where trigger_id='bps_file_report' | |
delete from sym_file_trigger where trigger_id='bps_file_report' | |
delete from sym_router where router_id='reportfiles_bps2swd' | |
INSERT INTO [dbo].[sym_file_trigger] | |
([trigger_id] | |
,[channel_id] | |
,[reload_channel_id] | |
,[base_dir] | |
,[recurse] | |
,[includes_files] | |
,[excludes_files] | |
,[sync_on_create] | |
,[sync_on_modified] | |
,[sync_on_delete] | |
,[sync_on_ctl_file] | |
,[delete_after_sync] | |
,[before_copy_script] | |
,[after_copy_script] | |
,[create_time] | |
,[last_update_by] | |
,[last_update_time] | |
,[description]) | |
VALUES | |
('bps_file_report' | |
,'filesync' | |
,'filesync_reload' | |
,'c:\bps-reports\' | |
,0 -- recurse | |
,'*.txt' | |
,NULL -- exclude files | |
,1 -- sync on create | |
,0 -- sync on modified | |
,0 -- sync on delete | |
,0 -- sync on ctl file | |
,1 -- delete after sync | |
,'targetFileName = sourceNodeId + "_" + sourceFileName;' -- before script | |
,NULL -- after script | |
,CURRENT_TIMESTAMP | |
,'bob' | |
,CURRENT_TIMESTAMP | |
,'syncing bps files') | |
INSERT INTO [dbo].[sym_router] | |
([router_id] | |
,[source_node_group_id] | |
,[target_node_group_id] | |
,[router_type] | |
,[sync_on_update] | |
,[sync_on_insert] | |
,[sync_on_delete] | |
,[create_time] | |
,[last_update_by] | |
,[last_update_time] | |
,[description]) | |
VALUES | |
('reportfiles_bps2swd' | |
,'bps' | |
,'swd' | |
,'default' | |
,0 -- sync on update | |
,1 -- sync on insert | |
,0 -- sync on delete | |
,CURRENT_TIMESTAMP | |
,'bob' | |
,CURRENT_TIMESTAMP | |
,'transfer report files to central server') | |
INSERT INTO [dbo].[sym_file_trigger_router] | |
([trigger_id] | |
,[router_id] | |
,[enabled] | |
,[initial_load_enabled] | |
,[target_base_dir] | |
,[conflict_strategy] | |
,[create_time] | |
,[last_update_by] | |
,[last_update_time] | |
,[description]) | |
VALUES | |
('bps_file_report' | |
,'reportfiles_bps2swd' | |
,1 -- enabled | |
,1 -- initial load | |
,'C:\report-collection' | |
,'SOURCE_WINS' -- values: source_wins, target_wins, manual | |
,CURRENT_TIMESTAMP | |
,'bob' | |
,CURRENT_TIMESTAMP | |
,'') | |
commit tran |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 14'000 Guid-Strings are approx 1MB | |
#$tmp = "C:\tmp\file_" + (Get-Random) | |
$tmp = "C:\tmp\r_" + (Get-Random) + ".txt" | |
$sizeMb = (Get-Random -Minimum 0.1 -Maximum 2.5) | |
$sb = [System.Text.StringBuilder]::new() | |
1.. [Int] (14000 * $sizeMb) | %{ [void]$sb.AppendLine(([guid]::newguid()).Guid)} | |
$sb.ToString() > $tmp | |
$hash = (Get-FileHash -Algorithm MD5 -Path $tmp).Hash | |
Copy-Item -Path $tmp -Destination "C:\bps-reports\random_md5_$hash.txt" | |
Delete-Item -Path $tmp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment