# copy only latest backup to remote server

**URL:** <https://forums.powershell.org/t/copy-only-latest-backup-to-remote-server/15594>\
**Category:** PowerShell Help\
**Created:** [February 5, 2021, 11:18pm UTC](https://forums.powershell.org/t/copy-only-latest-backup-to-remote-server/15594 "2021-02-05T23:18:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mercyangel](https://avatars.discourse-cdn.com/v4/letter/m/ed655f/32.png) [@mercyangel](https://forums.powershell.org/u/mercyangel)\
**Post date:** [February 5, 2021, 11:18pm UTC](https://forums.powershell.org/t/copy-only-latest-backup-to-remote-server/15594/1 "2021-02-05T23:18:12Z")

</div>

i awm having some windows backup folder and want to put it on some samba share folder to create a backups, problem is that in windows it creates every day backups, and i want only the latest. Files are named like: Backkup1.zip, Backkup2.zip, etc.

> $backuppath = "D:test" get-childitem -path $backuppath
> 
> get-childitem -path $backuppath -Filter “Backkup\*.zip” |
> 
> where-object { -not $\_.PSIsContainer } |
> 
> sort-object -Property $\_.CreationTime |
> 
> select-object -last 1 | pscp -pw mypass -r $Path [user@192.168.12.20](mailto:user@192.168.12.20):/mnt/DatabaseBackup

  
&nbsp;

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:27pm UTC](https://forums.powershell.org/t/copy-only-latest-backup-to-remote-server/15594/2 "2024-05-16T20:27:53Z")

</div>

Closed on May 16, 2024, 8:27pm UTC


